start dailymotion support, improve vendor support
This commit is contained in:
parent
1926c3bcd6
commit
a1ce8b794b
|
@ -0,0 +1,23 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// list dailymotion servers
|
||||||
|
|
||||||
|
type DailymotionVPN struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DailymotionVPN) ServerList() (error, *map[string]string) {
|
||||||
|
VPNNames := map[string]string{
|
||||||
|
"Paris 1": "gate-01.dc3.dailmotion.com",
|
||||||
|
"New-York 1": "gate-01.nyc.dailmotion.com",
|
||||||
|
"Silicon Valley 1": "gate-01.sv6.dailmotion.com",
|
||||||
|
"Singapore 1": "gate-01.sg1.dailmotion.com",
|
||||||
|
"Tokyo 1": "gate-01.ty4.dailmotion.com",
|
||||||
|
"Paris 2": "gate-01.dc3.dailmotion.com",
|
||||||
|
"New-York 2": "gate-01.nyc.dailmotion.com",
|
||||||
|
"Silicon Valley 2": "gate-01.sv6.dailmotion.com",
|
||||||
|
"Singapore 2": "gate-01.sg1.dailmotion.com",
|
||||||
|
"Tokyo 2": "gate-01.ty4.dailmotion.com",
|
||||||
|
"default": "vpn.dailymotion.com",
|
||||||
|
}
|
||||||
|
return nil, &VPNNames
|
||||||
|
}
|
|
@ -18,10 +18,10 @@ import (
|
||||||
type ExpressVPN struct {
|
type ExpressVPN struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ExpressVPN) ServerList() (error, *[]string) {
|
func (s *ExpressVPN) ServerList() (error, *map[string]string) {
|
||||||
var mux sync.Mutex
|
var mux sync.Mutex
|
||||||
requestCount := 0
|
requestCount := 0
|
||||||
VPNNames := map[string]bool{}
|
VPNNames := map[string]string{}
|
||||||
|
|
||||||
// Create HTTP client with timeout
|
// Create HTTP client with timeout
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
|
@ -67,14 +67,15 @@ func (s *ExpressVPN) ServerList() (error, *[]string) {
|
||||||
|
|
||||||
requestCount++
|
requestCount++
|
||||||
go func(line string) {
|
go func(line string) {
|
||||||
|
conv := "%s-ca-version-2.expressnetw.com"
|
||||||
line = strings.ToLower(line)
|
line = strings.ToLower(line)
|
||||||
line = strings.Replace(line, " & ", "", -1)
|
line = strings.Replace(line, " & ", "", -1)
|
||||||
line = strings.Replace(line, " ", "", -1)
|
line = strings.Replace(line, " ", "", -1)
|
||||||
|
|
||||||
name := fmt.Sprintf("%s-ca-version-2.expressnetw.com", line)
|
name := fmt.Sprintf(conv, line)
|
||||||
if _, err := net.ResolveIPAddr("ip4", name); err == nil {
|
if _, err := net.ResolveIPAddr("ip4", name); err == nil {
|
||||||
mux.Lock()
|
mux.Lock()
|
||||||
VPNNames[name] = true
|
VPNNames[line] = name
|
||||||
mux.Unlock()
|
mux.Unlock()
|
||||||
}
|
}
|
||||||
requestCount--
|
requestCount--
|
||||||
|
@ -90,11 +91,5 @@ func (s *ExpressVPN) ServerList() (error, *[]string) {
|
||||||
return errors.New("Can't get a list of VPN endpoints"), nil
|
return errors.New("Can't get a list of VPN endpoints"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the right values
|
return nil, &VPNNames
|
||||||
keys := make([]string, 0, len(VPNNames))
|
|
||||||
for k := range VPNNames {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, &keys
|
|
||||||
}
|
}
|
||||||
|
|
20
openvpn.go
20
openvpn.go
|
@ -41,12 +41,15 @@ func (v *OpenVpnSrv) Unlock() {
|
||||||
|
|
||||||
func NewOpenVpnSrv(conn net.Conn, mgt *OpenVpnMgt) *OpenVpnSrv {
|
func NewOpenVpnSrv(conn net.Conn, mgt *OpenVpnMgt) *OpenVpnSrv {
|
||||||
return &OpenVpnSrv{
|
return &OpenVpnSrv{
|
||||||
buf: bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)),
|
buf: bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)),
|
||||||
chanHold: make(chan bool),
|
chanHold: make(chan bool),
|
||||||
chanPass: make(chan OpenVpnPassword),
|
chanPass: make(chan OpenVpnPassword),
|
||||||
ret: make(chan []string),
|
ret: make(chan []string),
|
||||||
mgt: mgt,
|
mgt: mgt,
|
||||||
hold: false,
|
hold: false,
|
||||||
|
Status: "Starting",
|
||||||
|
Identifier: "Unknown",
|
||||||
|
Provider: "Unknown",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +101,9 @@ func (v *OpenVpnSrv) GetPid() error {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
v.mgt.SetPid(v, pid)
|
v.mgt.SetPid(v, pid)
|
||||||
v.mgt.Debug("Found PID", pid)
|
v.mgt.Debug("Found PID", pid)
|
||||||
|
if v.Identifier == "Unknown" {
|
||||||
|
v.Identifier = fmt.Sprintf("Unknown-%d", pid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -143,9 +149,9 @@ func (v *OpenVpnSrv) GetLine() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *OpenVpnSrv) ValidRemote(server, port, proto string) {
|
func (v *OpenVpnSrv) ValidRemote(server, port, proto string) {
|
||||||
|
v.Status = "Connected"
|
||||||
if v.Remote != "" {
|
if v.Remote != "" {
|
||||||
v.sendCommand([]string{fmt.Sprintf("remote MOD %s %s %s", v.Remote, port, proto)})
|
v.sendCommand([]string{fmt.Sprintf("remote MOD %s %s %s", v.Remote, port, proto)})
|
||||||
v.Status = "Connected"
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v.Remote = server
|
v.Remote = server
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type VpnProvider interface {
|
type VpnProvider interface {
|
||||||
ServerList() (error, *[]string)
|
ServerList() (error, *map[string]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OpenVpnMgt) getServerList(provider string) error {
|
func (s *OpenVpnMgt) getServerList(provider string) error {
|
||||||
|
@ -13,6 +13,10 @@ func (s *OpenVpnMgt) getServerList(provider string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
switch provider {
|
switch provider {
|
||||||
|
case "dailymotion":
|
||||||
|
list := DailymotionVPN{}
|
||||||
|
err, s.VpnRemotes[provider] = list.ServerList()
|
||||||
|
return err
|
||||||
case "expressvpn":
|
case "expressvpn":
|
||||||
list := ExpressVPN{}
|
list := ExpressVPN{}
|
||||||
err, s.VpnRemotes[provider] = list.ServerList()
|
err, s.VpnRemotes[provider] = list.ServerList()
|
||||||
|
|
|
@ -18,9 +18,9 @@ type OpenVpnMgt struct {
|
||||||
port string
|
port string
|
||||||
m sync.RWMutex
|
m sync.RWMutex
|
||||||
debug bool
|
debug bool
|
||||||
VpnRemotes map[string]*[]string `json:"remotes"`
|
VpnRemotes map[string]*map[string]string `json:"remotes"`
|
||||||
VpnServers map[int]*OpenVpnSrv `json:"sessions"`
|
VpnServers map[int]*OpenVpnSrv `json:"sessions"`
|
||||||
LastChange time.Time `json:"last_change"`
|
LastChange time.Time `json:"last_change"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer returns a pointer to a new server
|
// NewServer returns a pointer to a new server
|
||||||
|
@ -29,7 +29,7 @@ func NewVPNServer(port string, debug bool) *OpenVpnMgt {
|
||||||
port: port,
|
port: port,
|
||||||
debug: debug,
|
debug: debug,
|
||||||
VpnServers: make(map[int]*OpenVpnSrv),
|
VpnServers: make(map[int]*OpenVpnSrv),
|
||||||
VpnRemotes: make(map[string]*[]string),
|
VpnRemotes: make(map[string]*map[string]string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,29 +153,38 @@ select.interface {
|
||||||
last_change = data["last_change"];
|
last_change = data["last_change"];
|
||||||
$('#result>tbody').remove();
|
$('#result>tbody').remove();
|
||||||
$('#result').append('<tbody></ybody>');
|
$('#result').append('<tbody></ybody>');
|
||||||
remote = []
|
|
||||||
$.each(data, function(index, infos) {
|
$.each(data, function(index, infos) {
|
||||||
if (!infos) {
|
if (!infos) {
|
||||||
return;
|
return;
|
||||||
} else if (index == "remotes") {
|
} else if (index == "remotes") {
|
||||||
remotes = infos;
|
remotes = {};
|
||||||
|
$.each(infos, function(provider, list) {
|
||||||
|
remotes[provider]={};
|
||||||
|
var keys = [];
|
||||||
|
for (var key in list) {
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
keys.sort ();
|
||||||
|
for (i in keys) {
|
||||||
|
remotes[provider][keys[i]]=list[keys[i]];
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (index == "sessions") {
|
} else if (index == "sessions") {
|
||||||
$.each(infos, function(pid, infos) {
|
$.each(infos, function(pid, infos) {
|
||||||
line = '<tr>';
|
line = '<tr>';
|
||||||
line +='<td>'+infos['identifier']+'</td>';
|
line +='<td>'+infos['identifier']+'</td>';
|
||||||
line +='<td>'+infos['provider']+'</td>';
|
line +='<td>'+infos['provider']+'</td>';
|
||||||
if (possible=remotes[infos['provider']]) {
|
if (possible=remotes[infos['provider']]) {
|
||||||
possible.sort();
|
|
||||||
line += '<td><select id="server_'+pid+'" onchange="server_change('+pid+')">'
|
line += '<td><select id="server_'+pid+'" onchange="server_change('+pid+')">'
|
||||||
if (infos['active-vpn']=="") {
|
if (infos['active-vpn']=="") {
|
||||||
line += '<option value="">----------------</option>'
|
line += '<option value="">----------------</option>'
|
||||||
}
|
}
|
||||||
$.each(possible, function(i, remote) {
|
$.each(possible, function(name, remote) {
|
||||||
line += '<option value="'+remote+'"';
|
line += '<option value="'+remote+'"';
|
||||||
if(remote == infos['active-vpn']) {
|
if(remote == infos['active-vpn']) {
|
||||||
line += ' selected ';
|
line += ' selected ';
|
||||||
}
|
}
|
||||||
line += '>'+remote+'</option>';
|
line += '>'+name+'</option>';
|
||||||
});
|
});
|
||||||
line+='</select></td>'
|
line+='</select></td>'
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue