Beispiel #1
0
func Run() {

	fileName := "udp2tcp_debug.log"
	logFile, err := os.Create(fileName)
	defer logFile.Close()
	if err != nil {
		LOG.Fatalln("open file error !")
	}
	LOG = log.New(logFile, "[Debug]", log.Llongfile)

	idSessionMap = map[uint32]*udpsession.Session{}
	lock = new(sync.Mutex)
	// 启动udp服务器代理,并注册响应的回调函数
	ut = udptunnel.CreateServerTunnel(onData, LOG)
	ut.Handlers = make([]udptunnel.TunnelHandler, 0)
	utAddId := udptunnel.NewUtAddId(LOG)
	utAddId.LOG = LOG
	ut.Handlers = append(ut.Handlers, utAddId)
	nackModule := udptunnel.NewNack(LOG)
	ut.Handlers = append(ut.Handlers, nackModule)
	pacingModule := udptunnel.NewPacing(LOG)
	ut.Handlers = append(ut.Handlers, pacingModule)
	utWriter := udptunnel.NewUtWriter(LOG)
	ut.Handlers = append(ut.Handlers, utWriter)
	ut.InitHandlers()

	ut.StartServer()
}
Beispiel #2
0
func Run() {
	s := utils.MAX_ID
	s++
	log.Println(s)

	fileName := "tcp2udp_debug.log"
	logFile, err := os.Create(fileName)
	defer logFile.Close()
	if err != nil {
		LOG.Fatalln("open file error !")
	}
	LOG = log.New(logFile, "[Debug]", log.Llongfile)
	/*LOG.Println("A debug message here")
	  LOG.SetPrefix("[Info]")
	  LOG.Println("A Info Message here ")
	  LOG.SetFlags(LOG.Flags() | log.LstdFlags)
	  LOG.Println("A different prefix")*/

	sessionCount = 0
	lock = new(sync.Mutex)
	idSessionMap = map[uint32]*udpsession.Session{}
	ut = udptunnel.CreateClientTunnel(onData, LOG)
	ut.Handlers = make([]udptunnel.TunnelHandler, 0)
	utAddId := udptunnel.NewUtAddId(LOG)
	ut.Handlers = append(ut.Handlers, utAddId)
	nackModule := udptunnel.NewNack(LOG)
	ut.Handlers = append(ut.Handlers, nackModule)
	pacingModule := udptunnel.NewPacing(LOG)
	ut.Handlers = append(ut.Handlers, pacingModule)
	utWriter := udptunnel.NewUtWriter(LOG)
	ut.Handlers = append(ut.Handlers, utWriter)

	ut.InitHandlers()
	initListen()
}