diff --git a/client-ctl.go b/client-ctl.go index 22bb96f..bb4b5ac 100644 --- a/client-ctl.go +++ b/client-ctl.go @@ -409,7 +409,7 @@ func (ctl *client_ctl_client_conns_id_routes) ServeHTTP(w http.ResponseWriter, r if jcr.ClientPeerAddr == "" { status_code = http.StatusBadRequest; w.WriteHeader(status_code) err = fmt.Errorf("blank client-peer-addr") - goto oops; + goto oops } server_peer_option = string_to_route_option(jcr.ServerPeerOption) diff --git a/client.go b/client.go index 9df211c..2667abf 100644 --- a/client.go +++ b/client.go @@ -181,7 +181,7 @@ func NewClientRoute(cts *ClientConn, id RouteId, client_peer_addr string, client r.peer_addr = client_peer_addr // client-side peer r.peer_name = client_peer_name // if the client_peer_addr is a domain name, it can't tell between tcp4 and tcp6 - r.peer_option = string_to_route_option(tcp_addr_str_class(client_peer_addr)) + r.peer_option = string_to_route_option(TcpAddrStrClass(client_peer_addr)) r.server_peer_addr = server_peer_svc_addr r.server_peer_net = server_peer_svc_net // permitted network for server-side peer @@ -1211,7 +1211,7 @@ func NewClient(ctx context.Context, logger Logger, ctl_addrs []string, ctl_prefi c.ctl = make([]*http.Server, len(ctl_addrs)) copy(c.ctl_addr, ctl_addrs) - hs_log = log.New(&client_ctl_log_writer{cli: &c}, "", 0); + hs_log = log.New(&client_ctl_log_writer{cli: &c}, "", 0) for i = 0; i < len(ctl_addrs); i++ { c.ctl[i] = &http.Server{ @@ -1449,7 +1449,7 @@ func (c *Client) RunCtlTask(wg *sync.WaitGroup) { if c.stop_req.Load() == false { // this guard has a flaw in that the stop request can be made // between the check above and net.Listen() below. - l, err = net.Listen(tcp_addr_str_class(cs.Addr), cs.Addr) + l, err = net.Listen(TcpAddrStrClass(cs.Addr), cs.Addr) if err == nil { if c.stop_req.Load() == false { // check it again to make the guard slightly more stable diff --git a/hodu.go b/hodu.go index c9db838..12c604c 100644 --- a/hodu.go +++ b/hodu.go @@ -43,7 +43,7 @@ type Service interface { WriteLog(id string, level LogLevel, fmtstr string, args ...interface{}) } -func tcp_addr_str_class(addr string) string { +func TcpAddrStrClass(addr string) string { // the string is supposed to be addr:port if len(addr) > 0 { diff --git a/server-proxy.go b/server-proxy.go index 668d000..baf8738 100644 --- a/server-proxy.go +++ b/server-proxy.go @@ -494,8 +494,8 @@ func (pxy *server_proxy_xterm_file) ServeHTTP(w http.ResponseWriter, req *http.R case "_redirect": // shorthand for /_ssh/{conn_id}/_/ // don't care about parameters following the path - status_code = http.StatusMovedPermanently; - w.Header().Set("Location", req.URL.Path + "_/"); + status_code = http.StatusMovedPermanently + w.Header().Set("Location", req.URL.Path + "_/") w.WriteHeader(status_code) case "_forbidden": status_code = http.StatusForbidden; w.WriteHeader(status_code) @@ -563,7 +563,7 @@ func (pxy *server_proxy_ssh_ws) connect_ssh (ctx context.Context, username strin } */ - addr = svc_addr_to_dst_addr(r.SvcAddr); + addr = svc_addr_to_dst_addr(r.SvcAddr) dialer = &net.Dialer{} conn, err = dialer.DialContext(ctx, "tcp", addr.String()) diff --git a/server.go b/server.go index 8a33d10..a46893f 100644 --- a/server.go +++ b/server.go @@ -1015,7 +1015,7 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs // --------------------------------------------------------- - hs_log = log.New(&server_http_log_writer{svr: &s}, "", 0); + hs_log = log.New(&server_http_log_writer{svr: &s}, "", 0) // --------------------------------------------------------- @@ -1212,7 +1212,7 @@ func (s *Server) RunCtlTask(wg *sync.WaitGroup) { // defeat hard-coded "tcp" in ListenAndServe() and ListenAndServeTLS() // err = cs.ListenAndServe() // err = cs.ListenAndServeTLS("", "") - l, err = net.Listen(tcp_addr_str_class(cs.Addr), cs.Addr) + l, err = net.Listen(TcpAddrStrClass(cs.Addr), cs.Addr) if err == nil { if s.stop_req.Load() == false { if s.ctltlscfg == nil { @@ -1255,7 +1255,7 @@ func (s *Server) RunPxyTask(wg *sync.WaitGroup) { s.log.Write("", LOG_INFO, "Proxy channel[%d] started on %s", i, s.pxy_addr[i]) if s.stop_req.Load() == false { - l, err = net.Listen(tcp_addr_str_class(cs.Addr), cs.Addr) + l, err = net.Listen(TcpAddrStrClass(cs.Addr), cs.Addr) if err == nil { if s.stop_req.Load() == false { if s.pxytlscfg == nil { // TODO: change this @@ -1298,7 +1298,7 @@ func (s *Server) RunWpxTask(wg *sync.WaitGroup) { s.log.Write("", LOG_INFO, "Wpx channel[%d] started on %s", i, s.wpx_addr[i]) if s.stop_req.Load() == false { - l, err = net.Listen(tcp_addr_str_class(cs.Addr), cs.Addr) + l, err = net.Listen(TcpAddrStrClass(cs.Addr), cs.Addr) if err == nil { if s.stop_req.Load() == false { if s.wpxtlscfg == nil { // TODO: change this @@ -1392,7 +1392,7 @@ func (s *Server) AddNewServerConn(remote_addr *net.Addr, local_addr *net.Addr, p _, ok = s.cts_map[s.cts_next_id] if !ok { assigned_id = s.cts_next_id - s.cts_next_id++; + s.cts_next_id++ if s.cts_next_id == 0 { s.cts_next_id++ } break } @@ -1412,7 +1412,7 @@ func (s *Server) AddNewServerConn(remote_addr *net.Addr, local_addr *net.Addr, p return nil, fmt.Errorf("existing client - %s", cts.RemoteAddr.String()) } s.cts_map_by_addr[cts.RemoteAddr] = &cts - s.cts_map[cts.Id] = &cts; + s.cts_map[cts.Id] = &cts s.stats.conns.Store(int64(len(s.cts_map))) s.cts_mtx.Unlock()