mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2025-08-12 11:59:18 +02:00
Prepare for merge
This commit is contained in:
parent
0566f90488
commit
e3ae09b525
4 changed files with 25 additions and 17 deletions
|
@ -45,8 +45,8 @@ func (s *AuthServiceImpl) Authenticate(ctx context.Context, message *auth.UserPa
|
||||||
})
|
})
|
||||||
|
|
||||||
r := &auth.AuthResponse{}
|
r := &auth.AuthResponse{}
|
||||||
r.Authenticated = true
|
r.Authenticated = false
|
||||||
return r, nil
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error authenticating user: %s due to: %s", message.Username, err)
|
log.Printf("Error authenticating user: %s due to: %s", message.Username, err)
|
||||||
r.Error = err.Error()
|
r.Error = err.Error()
|
||||||
|
|
|
@ -200,7 +200,6 @@ func main() {
|
||||||
} else {
|
} else {
|
||||||
gw.CheckHost = security.CheckHost
|
gw.CheckHost = security.CheckHost
|
||||||
}
|
}
|
||||||
gwserver = &gw
|
|
||||||
|
|
||||||
if conf.Server.Authentication == config.AuthenticationBasic {
|
if conf.Server.Authentication == config.AuthenticationBasic {
|
||||||
h := web.BasicAuthHandler{SocketAddress: conf.Server.AuthSocket}
|
h := web.BasicAuthHandler{SocketAddress: conf.Server.AuthSocket}
|
||||||
|
@ -214,7 +213,6 @@ func main() {
|
||||||
}
|
}
|
||||||
http.Handle("/metrics", promhttp.Handler())
|
http.Handle("/metrics", promhttp.Handler())
|
||||||
http.HandleFunc("/tokeninfo", web.TokenInfo)
|
http.HandleFunc("/tokeninfo", web.TokenInfo)
|
||||||
http.HandleFunc("/list", List)
|
|
||||||
|
|
||||||
if conf.Server.Tls == config.TlsDisable {
|
if conf.Server.Tls == config.TlsDisable {
|
||||||
err = server.ListenAndServe()
|
err = server.ListenAndServe()
|
||||||
|
@ -225,14 +223,3 @@ func main() {
|
||||||
log.Fatal("ListenAndServe: ", err)
|
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 is the underlying connection with the client
|
||||||
tunnel *Tunnel
|
tunnel *Tunnel
|
||||||
|
|
||||||
|
// ctl is a channel to control the processor in case of events
|
||||||
|
ctl chan int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProcessor(gw *Gateway, tunnel *Tunnel) *Processor {
|
func NewProcessor(gw *Gateway, tunnel *Tunnel) *Processor {
|
||||||
|
@ -31,6 +34,7 @@ func NewProcessor(gw *Gateway, tunnel *Tunnel) *Processor {
|
||||||
gw: gw,
|
gw: gw,
|
||||||
state: SERVER_STATE_INITIALIZED,
|
state: SERVER_STATE_INITIALIZED,
|
||||||
tunnel: tunnel,
|
tunnel: tunnel,
|
||||||
|
ctl: make(chan int),
|
||||||
}
|
}
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
@ -168,8 +172,6 @@ func (p *Processor) Process(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
msg := p.channelCloseResponse(ERROR_SUCCESS)
|
msg := p.channelCloseResponse(ERROR_SUCCESS)
|
||||||
p.tunnel.Write(msg)
|
p.tunnel.Write(msg)
|
||||||
//p.tunnel.transportIn.Close()
|
|
||||||
//p.tunnel.transportOut.Close()
|
|
||||||
p.state = SERVER_STATE_CLOSED
|
p.state = SERVER_STATE_CLOSED
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
var Connections map[string]*Monitor
|
var Connections map[string]*Monitor
|
||||||
|
|
||||||
type Monitor struct {
|
type Monitor struct {
|
||||||
|
@ -7,6 +9,10 @@ type Monitor struct {
|
||||||
Tunnel *Tunnel
|
Tunnel *Tunnel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
ctlDisconnect = -1
|
||||||
|
)
|
||||||
|
|
||||||
func RegisterTunnel(t *Tunnel, p *Processor) {
|
func RegisterTunnel(t *Tunnel, p *Processor) {
|
||||||
if Connections == nil {
|
if Connections == nil {
|
||||||
Connections = make(map[string]*Monitor)
|
Connections = make(map[string]*Monitor)
|
||||||
|
@ -22,6 +28,19 @@ func RemoveTunnel(t *Tunnel) {
|
||||||
delete(Connections, t.Id)
|
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.
|
// CalculateSpeedPerSecond calculate moving average.
|
||||||
/*
|
/*
|
||||||
func CalculateSpeedPerSecond(connId string) (in int, out int) {
|
func CalculateSpeedPerSecond(connId string) (in int, out int) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue