mirror of
https://github.com/antoniomika/sish.git
synced 2025-12-24 13:37:57 +08:00
Use original address for forwarded channel. Fix #237
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
func handleAliasListener(check *channelForwardMsg, stringPort string, requestMessages string, listenerHolder *utils.ListenerHolder, state *utils.State, sshConn *utils.SSHConnection) (*utils.AliasHolder, *url.URL, string, string, error) {
|
||||
validAlias, aH := utils.GetOpenAlias(check.Addr, stringPort, state, sshConn)
|
||||
|
||||
if !strings.HasPrefix(validAlias, strings.ToLower(check.Addr)) && viper.GetBool("force-requested-aliases") || validAlias == "" {
|
||||
if !strings.HasPrefix(validAlias, check.Addr) && viper.GetBool("force-requested-aliases") || validAlias == "" {
|
||||
return nil, nil, "", "", fmt.Errorf("error assigning requested alias to tunnel")
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +250,8 @@ func handleAlias(newChannel ssh.NewChannel, sshConn *utils.SSHConnection, state
|
||||
return
|
||||
}
|
||||
|
||||
check.Addr = strings.ToLower(check.Addr)
|
||||
|
||||
tcpAliasToConnect := fmt.Sprintf("%s:%d", check.Addr, check.Port)
|
||||
loc, ok := state.AliasListeners.Load(tcpAliasToConnect)
|
||||
if !ok {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
func handleHTTPListener(check *channelForwardMsg, stringPort string, requestMessages string, listenerHolder *utils.ListenerHolder, state *utils.State, sshConn *utils.SSHConnection, scheme string) (*utils.HTTPHolder, *url.URL, string, error) {
|
||||
hostUrl, pH := utils.GetOpenHost(check.Addr, state, sshConn)
|
||||
|
||||
if (hostUrl == nil || !strings.HasPrefix(hostUrl.Host, strings.ToLower(check.Addr))) && viper.GetBool("force-requested-subdomains") {
|
||||
if (hostUrl == nil || !strings.HasPrefix(hostUrl.Host, check.Addr)) && viper.GetBool("force-requested-subdomains") {
|
||||
return nil, nil, "", fmt.Errorf("error assigning requested subdomain to tunnel")
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ func handleRemoteForward(newRequest *ssh.Request, sshConn *utils.SSHConnection,
|
||||
log.Println("Error unmarshaling remote forward payload:", err)
|
||||
}
|
||||
|
||||
originalAddress := check.Addr
|
||||
check.Addr = strings.ToLower(check.Addr)
|
||||
|
||||
bindPort := check.Rport
|
||||
@@ -299,9 +300,9 @@ func handleRemoteForward(newRequest *ssh.Request, sshConn *utils.SSHConnection,
|
||||
}
|
||||
|
||||
resp := &forwardedTCPPayload{
|
||||
Addr: check.Addr,
|
||||
Addr: originalAddress,
|
||||
Port: portChannelForwardReplyPayload.Rport,
|
||||
OriginAddr: check.Addr,
|
||||
OriginAddr: originalAddress,
|
||||
OriginPort: portChannelForwardReplyPayload.Rport,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user