added hostname passthrough
This commit is contained in:
@@ -17,6 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
MachineName string
|
||||
IPTable string
|
||||
DockerContainers string
|
||||
DefaultDockerFile string
|
||||
@@ -126,6 +127,13 @@ func SetDefaults() error {
|
||||
defaults["ServerPort"] = "8088"
|
||||
defaults["FRPServerPort"] = "0"
|
||||
defaults["BehindNAT"] = "True"
|
||||
// Random name generator
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defaults["MachineName"] = hostname
|
||||
//defaults["NetworkInterface"] = "wlp0s20f3"
|
||||
//defaults["NetworkInterfaceIPV6Index"] = "2"
|
||||
|
||||
|
||||
1
go.mod
1
go.mod
@@ -12,6 +12,7 @@ require (
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/go-git/go-git/v5 v5.4.2
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible
|
||||
github.com/moby/sys/mount v0.2.0 // indirect
|
||||
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -451,6 +451,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
|
||||
github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg=
|
||||
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e h1:XmA6L9IPRdUr28a+SK/oMchGgQy159wvzXA5tJ7l+40=
|
||||
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e/go.mod h1:AFIo+02s+12CEg8Gzz9kzhCbmbq6JcKNrhHffCGA9z4=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
||||
github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
|
||||
@@ -18,6 +18,7 @@ type IpAddresses struct {
|
||||
}
|
||||
|
||||
type IpAddress struct {
|
||||
Name string `json:"Name"`
|
||||
Ipv4 string `json:"ipv4"`
|
||||
Ipv6 string `json:"ipv6"`
|
||||
Latency time.Duration `json:"latency"`
|
||||
@@ -71,6 +72,7 @@ func ReadIpTable() (*IpAddresses, error) {
|
||||
PublicIP.Ipv4 = ip
|
||||
PublicIP.Ipv6 = ipv6
|
||||
PublicIP.ServerPort = config.ServerPort
|
||||
PublicIP.Name = config.MachineName
|
||||
if config.FRPServerPort != "0" {
|
||||
PublicIP.ProxyPort = config.FRPServerPort
|
||||
}
|
||||
|
||||
@@ -189,6 +189,7 @@ func Server() error {
|
||||
ProxyIpAddr.Ipv4 = lowestLatencyIpAddress.Ipv4
|
||||
ProxyIpAddr.ServerPort = proxyPort
|
||||
ProxyIpAddr.ProxyPort = lowestLatencyIpAddress.ProxyPort
|
||||
ProxyIpAddr.Name = config.MachineName
|
||||
|
||||
// append the following to the ip table
|
||||
table.IpAddress = append(table.IpAddress, ProxyIpAddr)
|
||||
|
||||
Reference in New Issue
Block a user