This commit is contained in:
Özgür Kesim 2013-07-30 13:20:53 +02:00
parent 87e9f8152f
commit 7648733aaa

View File

@ -2,10 +2,10 @@ package main
import (
"crypto/tls"
"log"
"net"
"flag"
"fmt"
"log"
"net"
"os"
"os/exec"
"syscall"
@ -14,17 +14,17 @@ import (
var (
cfile = flag.String("cert", "cert.pem", "Certificate file in PEM format")
kfile = flag.String("key", "key.pem", "Key file in PEM format")
port = flag.Int("port", 1234, "Port to bind to")
uid = flag.Int("uid", -1, "UID to run under")
gid = flag.Int("gid", -1, "GID to run under")
args []string
port = flag.Int("port", 1234, "Port to bind to")
uid = flag.Int("uid", -1, "UID to run under")
gid = flag.Int("gid", -1, "GID to run under")
args []string
nargs int
)
func main() {
flag.Parse()
args = flag.Args()
args = flag.Args()
nargs = flag.NArg()
if nargs < 1 {
fmt.Println("Usage: tlsserver [options] cmd [flags for cmd]")
@ -46,7 +46,7 @@ func main() {
// start listening
sport := fmt.Sprintf(":%d", *port)
sock, err := tls.Listen("tcp", sport , tconf)
sock, err := tls.Listen("tcp", sport, tconf)
if err != nil {
fmt.Println("error with tcp-socket:", err)
os.Exit(3)
@ -70,8 +70,6 @@ func main() {
}
}
// accept-loop
for {
conn, err := sock.Accept()
@ -105,7 +103,7 @@ func handleConnection(conn net.Conn) {
log.Println(err)
return
}
cmd.Env = make([]string,0)
cmd.Env = make([]string, 0)
cmd.Env = append(cmd.Env, "PATH="+os.Getenv("PATH"))
cmd.Env = append(cmd.Env, "PROTO=TCP")
cmd.Env = append(cmd.Env, "TCPLOCALIP="+lh)