From 27b09f5b883a93ca22e20a0460f86391ae3f469f Mon Sep 17 00:00:00 2001 From: rickiey Date: Fri, 24 Mar 2023 11:17:10 +0800 Subject: [PATCH 1/3] chore:add graphql server listen address config --- gql/server.go | 4 +++- node/config/def.go | 3 ++- node/config/types.go | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gql/server.go b/gql/server.go index b6114c7ef..fc857057a 100644 --- a/gql/server.go +++ b/gql/server.go @@ -46,6 +46,8 @@ func (s *Server) Start(ctx context.Context) error { // Serve dummy deals port := int(s.resolver.cfg.Graphql.Port) + bindAddress := s.resolver.cfg.Graphql.ListenAddress + err = serveDummyDeals(mux, port) if err != nil { return err @@ -72,7 +74,7 @@ func (s *Server) Start(ctx context.Context) error { } wsHandler := graphqlws.NewHandlerFunc(schema, queryHandler, wsOpts...) - listenAddr := fmt.Sprintf(":%d", port) + listenAddr := fmt.Sprintf("%s:%d", bindAddress, port) s.srv = &http.Server{Addr: listenAddr, Handler: mux} fmt.Printf("Graphql server listening on %s\n", listenAddr) mux.Handle("/graphql/subscription", &corsHandler{wsHandler}) diff --git a/node/config/def.go b/node/config/def.go index 1cd5bbc6b..052e69476 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -63,7 +63,8 @@ func DefaultBoost() *Boost { }, Graphql: GraphqlConfig{ - Port: 8080, + ListenAddress: "127.0.0.1", + Port: 8080, }, Tracing: TracingConfig{ diff --git a/node/config/types.go b/node/config/types.go index 631ec577f..5da180d7c 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -73,6 +73,8 @@ type WalletsConfig struct { } type GraphqlConfig struct { + // ListenAddress: default: 127.0.0.1 + ListenAddress string // The port that the graphql server listens on Port uint64 } From 53adfe3c0385b685c3b8204f2eac2ca9b996b34c Mon Sep 17 00:00:00 2001 From: rickiey <34705031+rickiey@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:44:44 +0800 Subject: [PATCH 2/3] Update node/config/types.go Co-authored-by: Jacob Heun --- node/config/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/config/types.go b/node/config/types.go index 5da180d7c..92dfee938 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -73,7 +73,7 @@ type WalletsConfig struct { } type GraphqlConfig struct { - // ListenAddress: default: 127.0.0.1 + // The ip address the GraphQL server will bind to. Default: 0.0.0.0 ListenAddress string // The port that the graphql server listens on Port uint64 From d9dcba5f3e35212006f3e7def399c3b67e35ea33 Mon Sep 17 00:00:00 2001 From: rickiey <34705031+rickiey@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:44:51 +0800 Subject: [PATCH 3/3] Update node/config/def.go Co-authored-by: Jacob Heun --- node/config/def.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/config/def.go b/node/config/def.go index 052e69476..6bb9df252 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -63,7 +63,7 @@ func DefaultBoost() *Boost { }, Graphql: GraphqlConfig{ - ListenAddress: "127.0.0.1", + ListenAddress: "0.0.0.0", Port: 8080, },