File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import (
17
17
"io/ioutil"
18
18
"net"
19
19
"os"
20
+ "regexp"
20
21
"strings"
21
22
"time"
22
23
@@ -203,6 +204,17 @@ func genKey(user, host string) string {
203
204
return fmt .Sprintf ("%s@%s" , user , host )
204
205
}
205
206
207
+ // getUserFromKey returns the user from the key used in the proxiedConnections global variable.
208
+ func getUserFromKey (key string ) (string , error ) {
209
+ re := regexp .MustCompile (`^(\w*)@` )
210
+ match := re .FindStringSubmatch (key )
211
+ if len (match ) < 2 {
212
+ return "" , errors .New ("Unable to extract user from given key (" + key + ")" )
213
+ } else {
214
+ return match [1 ], nil
215
+ }
216
+ }
217
+
206
218
// getAlgorithmAndRoutes returns the selection algorithm and a slice with the
207
219
// possible destinations from the global configuration for a user connected to
208
220
// an hostport and belonging to groups.
You can’t perform that action at this time.
0 commit comments