Skip to content

Commit

Permalink
var-naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmr-bot committed Aug 16, 2023
1 parent 679a798 commit a7d6ae7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions pkg/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func ParseClientConfig(fileContent string) (
err error,
) {
var content []byte

content = []byte(fileContent)

configBuffer := bytes.NewBuffer(nil)
Expand Down
20 changes: 10 additions & 10 deletions pkg/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ type ServerCommonConf struct {
// Dashboard port must be set first.
PprofEnable bool `ini:"pprof_enable" json:"pprof_enable"`
// Enable API Service
EnableApi bool `json:"api_enable"`
EnableAPI bool `json:"api_enable"`
// GET API BaseUrl
ApiBaseUrl string `json:"api_baseurl"`
APIBaseURL string `json:"api_baseurl"`
// Get API Token
ApiToken string `json:"api_token"`
APIToken string `json:"api_token"`
// NatHoleAnalysisDataReserveHours specifies the hours to reserve nat hole analysis data.
NatHoleAnalysisDataReserveHours int64 `ini:"nat_hole_analysis_data_reserve_hours" json:"nat_hole_analysis_data_reserve_hours"`
}
Expand Down Expand Up @@ -229,9 +229,9 @@ func GetDefaultServerConf() ServerCommonConf {
UserConnTimeout: 10,
HTTPPlugins: make(map[string]plugin.HTTPPluginOptions),
UDPPacketSize: 1500,
EnableApi: false,
ApiBaseUrl: "",
ApiToken: "",
EnableAPI: false,
APIBaseURL: "",
APIToken: "",
NatHoleAnalysisDataReserveHours: 7 * 24,
}
}
Expand Down Expand Up @@ -278,19 +278,19 @@ func UnmarshalServerConfFromIni(source interface{}) (ServerCommonConf, error) {

tmpStr = s.Key("api_enable").String()
if tmpStr == "false" {
common.EnableApi = false
common.EnableAPI = false
} else {
common.EnableApi = true
common.EnableAPI = true
}

tmpStr = s.Key("api_baseurl").String()
if tmpStr == s.Key("api_baseurl").String() {
common.ApiBaseUrl = tmpStr
common.APIBaseURL = tmpStr
}

tmpStr = s.Key("api_token").String()
if tmpStr == s.Key("api_token").String() {
common.ApiToken = tmpStr
common.APIToken = tmpStr
}

// plugin.xxx
Expand Down
4 changes: 2 additions & 2 deletions server/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ func (ctl *Control) HandleNatHoleReport(m *msg.NatHoleReport) {
func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy, LoginMsg *msg.Login) (remoteAddr string, err error) {
var pxyConf config.ProxyConf

s, err := api.NewService(ctl.serverCfg.ApiBaseUrl)
s, err := api.NewService(ctl.serverCfg.APIBaseURL)

var workConn proxy.GetWorkConnFn = ctl.GetWorkConn

Expand All @@ -568,7 +568,7 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy, LoginMsg *msg.Login) (re
if ctl.serverCfg.EnableApi {

Check failure on line 568 in server/control.go

View workflow job for this annotation

GitHub Actions / lint

ctl.serverCfg.EnableApi undefined (type config.ServerCommonConf has no field or method EnableApi) (typecheck)

Check failure on line 568 in server/control.go

View workflow job for this annotation

GitHub Actions / lint

ctl.serverCfg.EnableApi undefined (type config.ServerCommonConf has no field or method EnableApi)) (typecheck)

nowTime := time.Now().Unix()
ok, err := s.CheckProxy(ctl.loginMsg.User, pxyMsg, nowTime, ctl.serverCfg.ApiToken, LoginMsg)
ok, err := s.CheckProxy(ctl.loginMsg.User, pxyMsg, nowTime, ctl.serverCfg.APIToken, LoginMsg)

if err != nil {
return remoteAddr, err
Expand Down
8 changes: 4 additions & 4 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ func (svr *Service) RegisterControl(ctlConn net.Conn, loginMsg *msg.Login) (err
outLimit uint64
)

if svr.cfg.EnableApi {
if svr.cfg.EnableAPI {

nowTime := time.Now().Unix()

s, err := api.NewService(svr.cfg.ApiBaseUrl)
s, err := api.NewService(svr.cfg.APIBaseURL)
if err != nil {
return err
}
Expand All @@ -604,7 +604,7 @@ func (svr *Service) RegisterControl(ctlConn net.Conn, loginMsg *msg.Login) (err
}

// Connect to API server and verify the user.
valid, err := s.CheckToken(loginMsg.User, loginMsg.PrivilegeKey, nowTime, svr.cfg.ApiToken)
valid, err := s.CheckToken(loginMsg.User, loginMsg.PrivilegeKey, nowTime, svr.cfg.APIToken)

if err != nil {
return err
Expand All @@ -614,7 +614,7 @@ func (svr *Service) RegisterControl(ctlConn net.Conn, loginMsg *msg.Login) (err
return fmt.Errorf("authorization failed")
}

inLimit, outLimit, err = s.GetProxyLimit(loginMsg.User, nowTime, svr.cfg.ApiToken)
inLimit, outLimit, err = s.GetProxyLimit(loginMsg.User, nowTime, svr.cfg.APIToken)
if err != nil {
return err
}
Expand Down

0 comments on commit a7d6ae7

Please sign in to comment.