github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/third/kmgRadius/example/main.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/bronze1man/kmg/kmgConsole"
     5  	"github.com/bronze1man/kmg/kmgDebug"
     6  	"github.com/bronze1man/kmg/third/kmgRadius"
     7  )
     8  
     9  func main() {
    10  	// run the server in a new thread.
    11  	// 在一个新线程里面一直运行服务器.
    12  	kmgRadius.RunServer(":1812", []byte("sEcReT"), kmgRadius.Handler{
    13  		Auth: func(username string) (password string, exist bool) {
    14  			if username != "a" {
    15  				return "", false
    16  			}
    17  			return "b", true
    18  		},
    19  		AcctStart: func(req kmgRadius.AcctRequest) {
    20  			kmgDebug.Println("start", req)
    21  		},
    22  		AcctUpdate: func(req kmgRadius.AcctRequest) {
    23  			kmgDebug.Println("update", req)
    24  		},
    25  		AcctStop: func(req kmgRadius.AcctRequest) {
    26  			kmgDebug.Println("stop", req)
    27  		},
    28  	})
    29  	// wait for the system sign or ctrl-c to close the process.
    30  	// 等待系统信号或者ctrl-c 关闭进程
    31  	kmgConsole.WaitForExit()
    32  }