From 3c1cbfc255123074005eb6a77e36bd2fbeafef0a Mon Sep 17 00:00:00 2001
From: allen <allen@vite.org>
Date: Thu, 1 Dec 2022 02:30:54 +0800
Subject: [PATCH] feat: disable private http by default

---
 common/default_params.go | 1 -
 node/config/defaults.go  | 1 -
 rpc/endpoints.go         | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/common/default_params.go b/common/default_params.go
index eae6582c6..e44cf177c 100644
--- a/common/default_params.go
+++ b/common/default_params.go
@@ -10,7 +10,6 @@ import (
 const (
 	DefaultHTTPHost = "localhost" // Default host interface for the HTTP RPC server
 	DefaultHTTPPort = 48132       // Default TCP port for the HTTP RPC server
-	DefaultPrivateHTTPPort = 48133// Default TCP port for the private HTTP RPC server
 	DefaultWSHost   = "localhost" // Default host interface for the websocket RPC server
 	DefaultWSPort   = 31420       // Default TCP port for the websocket RPC server
 	DefaultP2PPort  = 8483
diff --git a/node/config/defaults.go b/node/config/defaults.go
index ee6ac55e0..5593a582c 100644
--- a/node/config/defaults.go
+++ b/node/config/defaults.go
@@ -16,7 +16,6 @@ var DefaultNodeConfig = Config{
 	KeyStoreDir: DefaultDataDir(),
 	HttpPort:    common.DefaultHTTPPort,
 	WSPort:      common.DefaultWSPort,
-	PrivateHttpPort:    common.DefaultPrivateHTTPPort,
 
 	LogLevel:      "info",
 	HTTPCors:      []string{"*"},
diff --git a/rpc/endpoints.go b/rpc/endpoints.go
index 8729911a4..6aa6bd826 100644
--- a/rpc/endpoints.go
+++ b/rpc/endpoints.go
@@ -63,7 +63,7 @@ func StartHTTPEndpoint(endpoint string, privateEndpoint string, apis []API, modu
 
 	go NewHTTPServer(cors, vhosts, timeouts, handler).Serve(listener)
 
-	if privateBind {
+	if privateBind && len(privateEndpoint) > 0 {
 		if privateListener, err = net.Listen("tcp", privateEndpoint); err != nil {
 			return nil, nil, nil, nil, err
 		}