improved version of IPTable
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"ip_address": [
|
||||
{
|
||||
"Name": "Node1",
|
||||
"IPV4": "64.227.168.102",
|
||||
"IPV6": "",
|
||||
"Latency": 0,
|
||||
|
||||
@@ -123,8 +123,8 @@ func PrintIpTable() error {
|
||||
}
|
||||
|
||||
for i := 0; i < len(table.IpAddress); i++ {
|
||||
fmt.Printf("\nIP Address: %s\nIPV6: %s\nLatency: %s\nServerPort: %s\nbehindNAT: %s\nEscapeImplementation: %s\n-----------"+
|
||||
"-----------------\n", table.IpAddress[i].Ipv4, table.IpAddress[i].Ipv6,
|
||||
fmt.Printf("\nMachine Name: %s\nIP Address: %s\nIPV6: %s\nLatency: %s\nServerPort: %s\nbehindNAT: %s\nEscapeImplementation: %s\n-----------"+
|
||||
"-----------------\n", table.IpAddress[i].Name, table.IpAddress[i].Ipv4, table.IpAddress[i].Ipv6,
|
||||
table.IpAddress[i].Latency, table.IpAddress[i].ServerPort, table.IpAddress[i].NAT, table.IpAddress[i].EscapeImplementation)
|
||||
}
|
||||
//PrettyPrint(table)
|
||||
@@ -146,12 +146,15 @@ func (table *IpAddresses) RemoveDuplicates() error {
|
||||
// - Node is behind NAT and no escape implementation provided
|
||||
if (NoDuplicates.IpAddress[k].Ipv4 != "" && NoDuplicates.IpAddress[k].Ipv4 == table.IpAddress[i].Ipv4 &&
|
||||
NoDuplicates.IpAddress[k].ServerPort == table.IpAddress[i].ServerPort) ||
|
||||
(NoDuplicates.IpAddress[k].Ipv6 != "" && NoDuplicates.IpAddress[k].Ipv6 == table.IpAddress[i].Ipv6) ||
|
||||
(NoDuplicates.IpAddress[k].NAT == "True" && NoDuplicates.IpAddress[i].EscapeImplementation == "None") {
|
||||
(NoDuplicates.IpAddress[k].Ipv6 != "" && NoDuplicates.IpAddress[k].Ipv6 == table.IpAddress[i].Ipv6) {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if table.IpAddress[i].NAT == "True" && table.IpAddress[i].EscapeImplementation == "None" {
|
||||
Exists = true
|
||||
}
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ func Server() error {
|
||||
|
||||
// If there is a proxy port specified
|
||||
// then starts the FRP server
|
||||
if config.FRPServerPort != "0" {
|
||||
go frp.StartFRPProxyFromRandom()
|
||||
}
|
||||
//if config.FRPServerPort != "0" {
|
||||
// go frp.StartFRPProxyFromRandom()
|
||||
//}
|
||||
|
||||
// TODO check if IPV6 or Proxy port is specified
|
||||
// if not update current entry as proxy address
|
||||
@@ -210,6 +210,7 @@ func Server() error {
|
||||
ProxyIpAddr.Ipv4 = lowestLatencyIpAddress.Ipv4
|
||||
ProxyIpAddr.ServerPort = proxyPort
|
||||
ProxyIpAddr.Name = config.MachineName
|
||||
ProxyIpAddr.NAT = "False"
|
||||
ProxyIpAddr.EscapeImplementation = "FRP"
|
||||
|
||||
// append the following to the ip table
|
||||
|
||||
Reference in New Issue
Block a user