From e65fbafd3639b4f9a591490daa04f68426f7c6a9 Mon Sep 17 00:00:00 2001 From: mountain Date: Thu, 22 Jun 2023 16:50:04 +0900 Subject: [PATCH] =?UTF-8?q?noauth=EC=9D=BC=20=EB=95=8C=20=EB=A1=9C?= =?UTF-8?q?=EC=BB=AC=20=EC=95=84=EC=9D=B4=ED=94=BC=EB=A5=BC=20=EC=9D=BD?= =?UTF-8?q?=EC=96=B4=EC=84=9C=20=EC=A3=BC=EC=86=8C=EB=A5=BC=20=EB=A7=8C?= =?UTF-8?q?=EB=93=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4ae86f0a571b7887853027b328c26493fe78122b. --- core/maingate.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/core/maingate.go b/core/maingate.go index d7f41e7..4893a6f 100644 --- a/core/maingate.go +++ b/core/maingate.go @@ -10,6 +10,7 @@ import ( "io" "math/big" "math/rand" + "net" "net/http" "os" "strings" @@ -174,24 +175,8 @@ type Maingate struct { firebaseAppContext context.Context } -var collectionNameMod = int32(0) - // New : 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 if err := common.LoadConfig(&config); err != nil { return nil, err @@ -451,6 +436,19 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu if *noauth { 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{ ServiceDescriptionSummary: ServiceDescriptionSummary{ ServiceCode: "000000000000", @@ -461,7 +459,8 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu Priority: 0, State: DivisionState_FullOpen, }, - Url: fmt.Sprintf("http://%s/warehouse", host), + + Url: fmt.Sprintf("http://%s/warehouse", ipaddr), }, }, }