Skip to content
Permalink
Browse files

Better handle messages for specific configurations. Closes #9

  • Loading branch information...
antoniomika committed May 30, 2019
1 parent d4bd84c commit 63dfcb7b8aec81574c8791be4d0e29dff8384843
Showing with 21 additions and 2 deletions.
  1. +4 −0 README.md
  2. +2 −0 main.go
  3. +15 −2 requests.go
@@ -107,12 +107,16 @@ Usage of ./sish:
Whether or not to force a random subdomain (default true)
-sish.http string
The address to listen for HTTP connections (default "localhost:80")
-sish.httpport int
The port for HTTP connections. This is only for output messages (default 80)
-sish.https string
The address to listen for HTTPS connections (default "localhost:443")
-sish.httpsenabled
Whether or not to listen for HTTPS connections
-sish.httpspems string
The location of pem files for HTTPS (fullchain.pem and privkey.pem) (default "ssl/")
-sish.httpsport int
The port for HTTPS connections. This is only for output messages (default 443)
-sish.keysdir string
Directory for public keys for pubkey auth (default "pubkeys/")
-sish.password string
@@ -35,7 +35,9 @@ type State struct {
var (
serverAddr = flag.String("sish.addr", "localhost:2222", "The address to listen for SSH connections")
httpAddr = flag.String("sish.http", "localhost:80", "The address to listen for HTTP connections")
httpPort = flag.Int("sish.httpport", 80, "The port for HTTP connections. This is only for output messages")
httpsAddr = flag.String("sish.https", "localhost:443", "The address to listen for HTTPS connections")
httpsPort = flag.Int("sish.httpsport", 443, "The port for HTTPS connections. This is only for output messages")
verifySSL = flag.Bool("sish.verifyssl", true, "Whether or not to verify SSL on proxy connection")
httpsEnabled = flag.Bool("sish.httpsenabled", false, "Whether or not to listen for HTTPS connections")
redirectRoot = flag.Bool("sish.redirectroot", true, "Whether or not to redirect the root domain")
@@ -75,6 +75,15 @@ func handleRemoteForward(newRequest *ssh.Request, sshConn *SSHConnection, state
os.Remove(tmpfile.Name())
}()

connType := "tcp"
if stringPort == "80" {
connType = "http"
} else if stringPort == "443" {
connType = "https"
}

sshConn.Messages <- fmt.Sprintf("\nStarting SSH Fowarding service for %s:%s. Forwarded connections can be accessed via the following methods:", connType, stringPort)

if stringPort == "80" || stringPort == "443" {
scheme := "http"
if stringPort == "443" {
@@ -92,9 +101,13 @@ func handleRemoteForward(newRequest *ssh.Request, sshConn *SSHConnection, state
state.HTTPListeners.Store(host, pH)
defer state.HTTPListeners.Delete(host)

sshConn.Messages <- fmt.Sprintf("HTTP requests for 80 and 443 can be reached on host: %s", host)
sshConn.Messages <- fmt.Sprintf("HTTP: http://%s:%d", host, *httpPort)

if *httpsEnabled {
sshConn.Messages <- fmt.Sprintf("HTTPS: https://%s:%d", host, *httpsPort)
}
} else {
sshConn.Messages <- fmt.Sprintf("Connections being forwarded to %s:%d", *rootDomain, chanListener.Addr().(*net.TCPAddr).Port)
sshConn.Messages <- fmt.Sprintf("TCP: %s:%d", *rootDomain, chanListener.Addr().(*net.TCPAddr).Port)
}

go func() {

0 comments on commit 63dfcb7

Please sign in to comment.
You can’t perform that action at this time.