mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2026-03-27 22:46:37 +00:00
Prepare for merge
This commit is contained in:
@@ -45,8 +45,8 @@ func (s *AuthServiceImpl) Authenticate(ctx context.Context, message *auth.UserPa
|
||||
})
|
||||
|
||||
r := &auth.AuthResponse{}
|
||||
r.Authenticated = true
|
||||
return r, nil
|
||||
r.Authenticated = false
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error authenticating user: %s due to: %s", message.Username, err)
|
||||
r.Error = err.Error()
|
||||
|
||||
@@ -200,7 +200,6 @@ func main() {
|
||||
} else {
|
||||
gw.CheckHost = security.CheckHost
|
||||
}
|
||||
gwserver = &gw
|
||||
|
||||
if conf.Server.Authentication == config.AuthenticationBasic {
|
||||
h := web.BasicAuthHandler{SocketAddress: conf.Server.AuthSocket}
|
||||
@@ -214,7 +213,6 @@ func main() {
|
||||
}
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
http.HandleFunc("/tokeninfo", web.TokenInfo)
|
||||
http.HandleFunc("/list", List)
|
||||
|
||||
if conf.Server.Tls == config.TlsDisable {
|
||||
err = server.ListenAndServe()
|
||||
@@ -225,14 +223,3 @@ func main() {
|
||||
log.Fatal("ListenAndServe: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
var gwserver *protocol.Gateway
|
||||
|
||||
func List(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
for k, v := range protocol.Connections {
|
||||
fmt.Fprintf(w, "Id: %s Rdg-Id: %s User: %s From: %s Connected Since: %s Bytes Sent: %d Bytes Received: %d Last Seen: %s Target: %s\n",
|
||||
k, v.Tunnel.RDGId, v.Tunnel.UserName, v.Tunnel.RemoteAddr, v.Tunnel.ConnectedOn, v.Tunnel.BytesSent, v.Tunnel.BytesReceived,
|
||||
v.Tunnel.LastSeen, v.Tunnel.TargetServer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ type Processor struct {
|
||||
|
||||
// tunnel is the underlying connection with the client
|
||||
tunnel *Tunnel
|
||||
|
||||
// ctl is a channel to control the processor in case of events
|
||||
ctl chan int
|
||||
}
|
||||
|
||||
func NewProcessor(gw *Gateway, tunnel *Tunnel) *Processor {
|
||||
@@ -31,6 +34,7 @@ func NewProcessor(gw *Gateway, tunnel *Tunnel) *Processor {
|
||||
gw: gw,
|
||||
state: SERVER_STATE_INITIALIZED,
|
||||
tunnel: tunnel,
|
||||
ctl: make(chan int),
|
||||
}
|
||||
return h
|
||||
}
|
||||
@@ -168,8 +172,6 @@ func (p *Processor) Process(ctx context.Context) error {
|
||||
}
|
||||
msg := p.channelCloseResponse(ERROR_SUCCESS)
|
||||
p.tunnel.Write(msg)
|
||||
//p.tunnel.transportIn.Close()
|
||||
//p.tunnel.transportOut.Close()
|
||||
p.state = SERVER_STATE_CLOSED
|
||||
return nil
|
||||
default:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package protocol
|
||||
|
||||
import "fmt"
|
||||
|
||||
var Connections map[string]*Monitor
|
||||
|
||||
type Monitor struct {
|
||||
@@ -7,6 +9,10 @@ type Monitor struct {
|
||||
Tunnel *Tunnel
|
||||
}
|
||||
|
||||
const (
|
||||
ctlDisconnect = -1
|
||||
)
|
||||
|
||||
func RegisterTunnel(t *Tunnel, p *Processor) {
|
||||
if Connections == nil {
|
||||
Connections = make(map[string]*Monitor)
|
||||
@@ -22,6 +28,19 @@ func RemoveTunnel(t *Tunnel) {
|
||||
delete(Connections, t.Id)
|
||||
}
|
||||
|
||||
func Disconnect(id string) error {
|
||||
if Connections == nil {
|
||||
return fmt.Errorf("%s connection does not exist", id)
|
||||
}
|
||||
|
||||
if m, ok := Connections[id]; !ok {
|
||||
m.Processor.ctl <- ctlDisconnect
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s connection does not exist", id)
|
||||
}
|
||||
|
||||
// CalculateSpeedPerSecond calculate moving average.
|
||||
/*
|
||||
func CalculateSpeedPerSecond(connId string) (in int, out int) {
|
||||
|
||||
Reference in New Issue
Block a user