Skip to content

Commit 995c6e1

Browse files
committed
feature: Raw connection handling
1 parent 9d934d4 commit 995c6e1

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

app/routes/index.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,21 @@ import (
66
)
77

88
func Install(app *fiber.App) {
9-
app.Post("/extensionRunner", handlers.ExtensionRunner)
10-
app.Post("/commandRunner", handlers.CommandRunner)
9+
// extension
10+
app.Post("/run", handlers.ExtensionRunner)
11+
12+
// command
13+
app.Post("/runCommand", handlers.CommandRunner)
14+
app.Post("/runOutsideCommand", handlers.OutsideCommandRunner)
15+
16+
// tunnel
1117
app.Post("/openTunnel", handlers.OpenTunnel)
18+
app.Post("/keepTunnelAlive", handlers.KeepTunnelAlive)
19+
20+
// file
21+
app.Post("/getFile", handlers.GetFile)
22+
app.Post("/putFile", handlers.PutFile)
23+
24+
// script
25+
app.Post("/runScript", handlers.ScriptRunner)
1226
}

internal/bridge/connection.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ func (p *Pool) Set(userID, serverID string, session *Session) {
2828
Connections[userID+serverID] = session
2929
}
3030

31+
func (p *Pool) GetRaw(userID, remoteHost, username string) (*Session, error) {
32+
if conn, ok := Connections[userID+remoteHost+username]; ok {
33+
conn.LastConnection = time.Now()
34+
return conn, nil
35+
} else {
36+
return nil, errors.New("connection does not exist")
37+
}
38+
}
39+
40+
func (p *Pool) SetRaw(userID, remoteHost, username string, session *Session) {
41+
Connections[userID+remoteHost+username] = session
42+
}
43+
3144
func (p *Pool) Delete(key string) {
3245
mutex.Lock()
3346
defer mutex.Unlock()

0 commit comments

Comments
 (0)