removed unneeded code
This commit is contained in:
parent
9d266180e9
commit
a5bb59622e
1
Makefile
1
Makefile
@ -41,7 +41,6 @@ CMD_SRCS=\
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(DATA) $(SRCS) $(CMD_DATA) $(CMD_SRCS)
|
||||
##go build -buildmode=plugin -o modres.so hook/modres.go
|
||||
##CGO_ENABLED=0 go build -x -ldflags "-X 'main.HODU_NAME=$(NAME)' -X 'main.HODU_VERSION=$(VERSION)'" -o $@ $(CMD_SRCS)
|
||||
CGO_ENABLED=1 go build -x -ldflags "-X 'main.HODU_NAME=$(NAME)' -X 'main.HODU_VERSION=$(VERSION)'" -o $@ $(CMD_SRCS)
|
||||
##CGO_ENABLED=1 go build -x -ldflags "-X 'main.HODU_NAME=$(NAME)' -X 'main.HODU_VERSION=$(VERSION)' -linkmode external -extldflags=-static" -o $@ $(CMD_SRCS)
|
||||
|
@ -1084,7 +1084,14 @@ func (c *Client) wrap_http_handler(handler ClientHttpHandler) http.Handler {
|
||||
var time_taken time.Duration
|
||||
|
||||
start_time = time.Now()
|
||||
|
||||
// TODO: some kind of authorization, especially for ctl
|
||||
//req.BasicAuth()
|
||||
//req.Header.Get("Authorization")
|
||||
|
||||
status_code, err = handler.ServeHTTP(w, req)
|
||||
|
||||
// TODO: statistics by status_code and end point types.
|
||||
time_taken = time.Now().Sub(start_time)
|
||||
|
||||
if status_code > 0 {
|
||||
|
@ -51,6 +51,10 @@ type server_proxy_xterm_file struct {
|
||||
file string
|
||||
}
|
||||
|
||||
type server_proxy_http_wpx struct {
|
||||
server_proxy
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
//Copied from net/http/httputil/reverseproxy.go
|
||||
@ -482,6 +486,22 @@ oops:
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
func (pxy *server_proxy_http_wpx) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
|
||||
var status_code int
|
||||
var err error
|
||||
|
||||
|
||||
status_code = http.StatusForbidden; w.WriteHeader(status_code)
|
||||
|
||||
// TODO: show the list of services running...
|
||||
//done:
|
||||
return status_code, nil
|
||||
|
||||
//oops:
|
||||
return status_code, err
|
||||
}
|
||||
// ------------------------------------
|
||||
|
||||
type server_proxy_xterm_session_info struct {
|
||||
ConnId string
|
||||
RouteId string
|
||||
|
38
server.go
38
server.go
@ -9,7 +9,6 @@ import "log"
|
||||
import "net"
|
||||
import "net/http"
|
||||
import "net/netip"
|
||||
import "plugin"
|
||||
import "strconv"
|
||||
import "sync"
|
||||
import "sync/atomic"
|
||||
@ -951,8 +950,6 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
|
||||
var i int
|
||||
var hs_log *log.Logger
|
||||
var opts []grpc.ServerOption
|
||||
var plgin *plugin.Plugin
|
||||
var plgsym plugin.Symbol
|
||||
var err error
|
||||
|
||||
if len(rpc_addrs) <= 0 {
|
||||
@ -1085,9 +1082,8 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
|
||||
s.wpx_mux = http.NewServeMux()
|
||||
s.wpx_mux.Handle("/{port_id}/{trailer...}",
|
||||
s.wrap_http_handler(&server_proxy_http_main{server_proxy: server_proxy{s: &s, id: "wpx"}, prefix: PORT_ID_MARKER}))
|
||||
s.wpx_mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
})
|
||||
s.wpx_mux.Handle("/",
|
||||
s.wrap_http_handler(&server_proxy_http_wpx{server_proxy: server_proxy{s: &s, id: "wpx"}}))
|
||||
|
||||
s.wpx_addr = make([]string, len(wpx_addrs))
|
||||
s.wpx = make([]*http.Server, len(wpx_addrs))
|
||||
@ -1109,36 +1105,6 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
|
||||
s.stats.peers.Store(0)
|
||||
s.stats.ssh_proxy_sessions.Store(0)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
plgin, err = plugin.Open("modres.so")
|
||||
if err == nil {
|
||||
plgsym, err = plgin.Lookup("Plugin")
|
||||
if err == nil {
|
||||
var plg ServerPluginInterface
|
||||
var ok bool
|
||||
|
||||
switch plgsym.(type) {
|
||||
case *ServerPluginInterface:
|
||||
var tmp *ServerPluginInterface
|
||||
tmp, ok = plgsym.(*ServerPluginInterface)
|
||||
if ok { plg = *tmp }
|
||||
case ServerPluginInterface:
|
||||
plg, ok = plgsym.(ServerPluginInterface)
|
||||
}
|
||||
//plg, ok = plgsym.(*ServerPluginInterface)
|
||||
if ok {
|
||||
plg.Init(&s)
|
||||
plg.Cleanup()
|
||||
} else {
|
||||
fmt.Printf ("YYYYYYYYYYYYYYY NOT OK\n")
|
||||
}
|
||||
} else {
|
||||
fmt.Printf ("YYYYYYYYYYYYYYY[%v]\n", err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf ("XXXXXX[%v]\n", err)
|
||||
}
|
||||
|
||||
return &s, nil
|
||||
|
||||
oops:
|
||||
|
Loading…
x
Reference in New Issue
Block a user