@ -10,6 +10,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -174,24 +175,8 @@ type Maingate struct {
|
|||||||
firebaseAppContext context.Context
|
firebaseAppContext context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
var collectionNameMod = int32(0)
|
|
||||||
|
|
||||||
// New :
|
// New :
|
||||||
func New(ctx context.Context) (*Maingate, error) {
|
func New(ctx context.Context) (*Maingate, error) {
|
||||||
if *devflag && atomic.AddInt32(&collectionNameMod, 1) == 1 {
|
|
||||||
hostname, _ := os.Hostname()
|
|
||||||
CollectionLink = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionLink)))
|
|
||||||
CollectionAuth = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionAuth)))
|
|
||||||
CollectionWhitelist = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionWhitelist)))
|
|
||||||
CollectionService = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionService)))
|
|
||||||
CollectionAccount = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionAccount)))
|
|
||||||
CollectionBlock = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionBlock)))
|
|
||||||
CollectionPlatformLoginToken = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionPlatformLoginToken)))
|
|
||||||
CollectionUserToken = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionUserToken)))
|
|
||||||
CollectionGamepotUserInfo = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionGamepotUserInfo)))
|
|
||||||
CollectionFirebaseUserInfo = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionFirebaseUserInfo)))
|
|
||||||
}
|
|
||||||
|
|
||||||
var config maingateConfig
|
var config maingateConfig
|
||||||
if err := common.LoadConfig(&config); err != nil {
|
if err := common.LoadConfig(&config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -451,6 +436,19 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
|||||||
|
|
||||||
if *noauth {
|
if *noauth {
|
||||||
host, _ := os.Hostname()
|
host, _ := os.Hostname()
|
||||||
|
addrs, err := net.InterfaceAddrs()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ipaddr := "127.0.0.1"
|
||||||
|
for _, addr := range addrs {
|
||||||
|
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||||
|
if ipnet.IP.To4() != nil {
|
||||||
|
ipaddr = ipnet.IP.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
empty := serviceDescription{
|
empty := serviceDescription{
|
||||||
ServiceDescriptionSummary: ServiceDescriptionSummary{
|
ServiceDescriptionSummary: ServiceDescriptionSummary{
|
||||||
ServiceCode: "000000000000",
|
ServiceCode: "000000000000",
|
||||||
@ -461,7 +459,8 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
|||||||
Priority: 0,
|
Priority: 0,
|
||||||
State: DivisionState_FullOpen,
|
State: DivisionState_FullOpen,
|
||||||
},
|
},
|
||||||
Url: fmt.Sprintf("http://%s/warehouse", host),
|
|
||||||
|
Url: fmt.Sprintf("http://%s/warehouse", ipaddr),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user