func (context *bootContext) startServer() { defer func() { ex.CatchException(advice(recover())) sigChan <- t.Bye }() conf, err := t.Parse_d5s_file(context.config) if err != nil { log.Fatalln(advice(err)) } context.setLogVerbose(conf.Verbose) log.Infoln(versionString()) log.Infoln("Server is listening on", conf.ListenAddr) ln, err := net.ListenTCP("tcp", conf.ListenAddr) if err != nil { log.Fatalln(err) } defer ln.Close() dhKey, _ := c.NewDHKey(DH_METHOD) server := t.NewServer(conf, dhKey) context.components = append(context.components, server) context.closeable = append(context.closeable, ln) for { conn, err := ln.AcceptTCP() if err == nil { go server.TunnelServe(conn) } else { t.SafeClose(conn) } } }
func (c *bootContext) cccHandler(output string) { // ./deblocus -ccc SERV_ADDR:PORT USER if flag.NArg() == 2 { addr := flag.Arg(0) v, err := t.IsValidHost(addr) fatalIf(!v, err) d5sc, err := t.Parse_d5s_file(c.config) fatalIf(err != nil, advice(err)) d5sc.Listen = addr err = t.CreateClientConfig(output, d5sc, flag.Arg(1)) fatalIf(err != nil, err) } else { fatal("Incorrect arguments") } }