本文整理汇总了Golang中github.com/KirisurfProject/kilog.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: proxhandler
func proxhandler(w http.ResponseWriter, req *http.Request) {
proxsemaph <- 0
defer func() {
<-proxsemaph
}()
kilog.Debug("haha")
xaxa := strings.Split(req.URL.Path, "/")
if len(xaxa) != 3 {
fmt.Println(xaxa)
return
}
uniqid := xaxa[2]
urlcache_lk.Lock()
megaurl := urlcache[uniqid]
fname := fnamecache[uniqid]
urlcache_lk.Unlock()
w.Header().Add("Content-Disposition", fmt.Sprintf("inline; filename=%s", fname))
kilog.Debug(megaurl)
// Spin off megadl
cmd := exec.Command("megadl", "--path", "-", megaurl)
pipe, err := cmd.StdoutPipe()
err = cmd.Start()
if err != nil {
kilog.Debug(err.Error())
return
}
go cmd.Wait()
defer cmd.Process.Kill()
io.Copy(w, pipe)
}
开发者ID:mehulsbhatt,项目名称:megaproxy,代码行数:34,代码来源:main.go
示例2: socksBeginConn
func socksBeginConn(proxy *net.TCPAddr) (toret io.ReadWriteCloser, err error) {
conn, err := net.DialTCP("tcp", nil, proxy)
if err != nil {
return
}
// Initial greeting: 0x05 0x01 0x00 (SOCKS5, 1 method, no authentication)
_, err = conn.Write([]byte{0x05, 0x01, 0x00})
if err != nil {
return
}
kilog.Debug("socks5: --> greeting")
// Server should respond: 0x05 0x00 (SOCKS5, no auth selected)
svresp := make([]byte, 2)
_, err = io.ReadFull(conn, svresp)
if err != nil || !(svresp[0] == 0x05 && svresp[1] == 0x00) {
if err == nil {
err = errors.New("socks5: server sent garbage")
}
return
}
kilog.Debug("socks5: <-- greeting")
toret = conn
return
}
开发者ID:ProjectNiwl,项目名称:danasi,代码行数:25,代码来源:socksConnect.go
示例3: HandleClient
func (srv *Server) HandleClient(raw io.ReadWriteCloser) {
defer raw.Close()
/*raw, err := kiss.LLObfsServerHandshake(srv.prv.PublicKey(), raw)
if err != nil {
kilog.Debug("directory: client failed LLObfs handshake: %v", err.Error())
return
}*/
var theirKey natrium.EdDSAPublic
// "verifier" that copies down their public key
copier := func(haha natrium.EdDSAPublic) bool {
theirKey = haha
return true
}
sock, err := kiss.KiSSNamedHandshake(srv.prv, copier, raw)
if err != nil {
kilog.Debug("directory: client failed KiSS handshake: %v", err.Error())
return
}
defer sock.Close()
var request clntRequest
err = struc.Unpack(sock, &request)
if err != nil {
kilog.Debug("directory: client sent malformed request: %v", err.Error())
return
}
//fmt.Println(request)
srv.rqDispatch(sock, request)
}
开发者ID:ProjectNiwl,项目名称:sagiri,代码行数:29,代码来源:server.go
示例4: addtocache
func addtocache(w http.ResponseWriter, req *http.Request) {
err := req.ParseForm()
if err != nil {
return
}
megaurl := req.Form.Get("megaurl")
kilog.Debug(megaurl)
uniqid := make([]byte, 16)
rand.Read(uniqid)
xaxa := make([]byte, 100)
base32.StdEncoding.Encode(xaxa, uniqid)
id := strings.Replace(strings.ToLower(string(xaxa[:base32.StdEncoding.EncodedLen(16)])), "=", "", -1)
kilog.Debug(id)
urlcache_lk.Lock()
urlcache[id] = megaurl
fnamecache[id] = req.Form.Get("filename")
urlcache_lk.Unlock()
fmt.Fprintf(w, `
<!DOCTYPE html>
<html>
<head>
<title>megaproxy</title>
</head>
<body>
Your <a href="dl/%s">proxied URL</a>
</body>
</html>`, id)
}
开发者ID:mehulsbhatt,项目名称:megaproxy,代码行数:31,代码来源:urlgen.go
示例5: tcpLoop
func tcpLoop() {
listener, err := net.ListenTCP("tcp", transThis)
if err != nil {
kilog.Critical("%v", err.Error())
os.Exit(-1)
}
for {
clnt, err := listener.AcceptTCP()
if err != nil {
kilog.Critical("%v", err.Error())
os.Exit(-1)
}
go func() {
defer clnt.Close()
defer clnt.CloseRead()
defer clnt.CloseWrite()
lol, err := clnt.File()
if err != nil {
panic(err.Error())
}
haha := C.getdestaddr_iptables(C.int(lol.Fd()))
lol.Close()
sdf := make([]byte, 4)
binary.LittleEndian.PutUint32(sdf, uint32(haha.sin_addr.s_addr))
port := binary.BigEndian.Uint16((*[2]byte)(unsafe.Pointer(&haha.sin_port))[:])
rmAddr := &net.TCPAddr{sdf, int(port), ""}
dnsLock.Lock()
rmName, ok := ipToName[rmAddr.IP.String()]
dnsLock.Unlock()
var rmConn io.ReadWriteCloser
// see if we should connect IP or name
if !ok {
kilog.Warning("unmapped IP received (%v), misconfig?", rmAddr)
rmConn, err = socksConnectIP(socksNext, rmAddr)
} else {
kilog.Debug("mapped IP received (%v -> %v)", rmAddr, rmName)
rmConn, err = socksConnectName(socksNext, rmName, rmAddr.Port)
}
if err != nil {
kilog.Debug("%v", err)
return
}
defer rmConn.Close()
go func() {
defer rmConn.Close()
defer clnt.Close()
defer clnt.CloseRead()
defer clnt.CloseWrite()
io.Copy(rmConn, clnt)
}()
io.Copy(clnt, rmConn)
kilog.Debug("closing client")
}()
}
}
开发者ID:ProjectNiwl,项目名称:danasi,代码行数:59,代码来源:tcpLoop.go
示例6: dnsHandle
// DNS requests go to this function
func dnsHandle(w dns.ResponseWriter, r *dns.Msg) {
name := r.Question[0].Name
if !namePattern.MatchString(name) {
kilog.Debug("%v does not match pattern, forwarding", name)
dnsForward(w, r)
return
}
// otherwise
kilog.Debug("%v matches pattern, handling", name)
dnsLock.Lock()
defer dnsLock.Unlock()
// check in table first
fakeIP, ok := nameToIP[name]
if !ok {
// place in table
var nwIP string
for {
haha := ipAlloc().String()
_, exists := ipToName[haha]
if exists {
continue
}
nwIP = haha
break
}
fakeIP = nwIP
nameToIP[name] = fakeIP
ipToName[fakeIP] = name
// remove in 30 minutes
go func() {
time.Sleep(time.Minute * 30)
dnsLock.Lock()
defer dnsLock.Unlock()
delete(nameToIP, name)
delete(ipToName, fakeIP)
}()
}
// return the fake IP to the user
resp := new(dns.A)
resp.Hdr.Name = name
resp.Hdr.Ttl = 1 // very short
resp.Hdr.Class = dns.ClassINET
resp.Hdr.Rrtype = dns.TypeA
resp.A = net.ParseIP(fakeIP)
towrite := new(dns.Msg)
towrite.Id = r.Id
towrite.RecursionAvailable = true
towrite.RecursionDesired = true
towrite.Response = true
towrite.Question = r.Question
towrite.Answer = make([]dns.RR, 1)
towrite.Answer[0] = resp
w.WriteMsg(towrite)
kilog.Debug("returning mapping %v -> %v", name, fakeIP)
}
开发者ID:ProjectNiwl,项目名称:danasi,代码行数:57,代码来源:dnsDispatch.go
示例7: do_AMB_REGISTER
func (ns *NodeState) do_AMB_REGISTER(sok io.ReadWriteCloser, req textprot.TextReq) (err error) {
if len(req.Args) == 0 {
err = errors.New("core2core: server got truncated AMB_REGISTER")
return
}
bts, err := hex.DecodeString(req.Args[0])
if err != nil {
return err
}
var kee [32]byte
copy(kee[:], bts)
fmt.Printf("%x\n", kee[:])
// unlock once the kiricom state is in place
ns.Lock()
_, ok := ns.ambState[kee]
if ok {
ns.Unlock()
err = (&textprot.TextReq{
Verb: "NOPE",
}).WriteTo(sok)
return
}
dieInDisgrace := func() {
ns.Lock()
delete(ns.ambState, kee)
ns.Unlock()
}
defer kilog.Debug("core2core: ambassador register for %x terminated", kee[:])
// signal OKAY
err = (&textprot.TextReq{
Verb: "OKAY",
}).WriteTo(sok)
if err != nil {
kilog.Debug("core2core: WHAT %v", err.Error())
dieInDisgrace()
return
}
// construct the client kiricom state
kcstat := kiricom.NewClientCtx(8192, sok)
ns.ambState[kee] = kcstat
ns.Unlock()
defer dieInDisgrace()
defer kcstat.Close()
kcstat.WaitDeath()
return
}
开发者ID:ProjectNiwl,项目名称:sagiri,代码行数:53,代码来源:do_AMB.go
示例8: BuildCircuit
func BuildCircuit(slc []dirclient.KNode, subchannel int) (io.ReadWriteCloser, error) {
// this returns a checker whether a public key is valid
pubkey_checker := func(hsh string) func([]byte) bool {
return func([]byte) bool { return true }
return func(xaxa []byte) bool {
hashed := hash_base32(xaxa)
return subtle.ConstantTimeCompare([]byte(hashed), []byte(hsh)) == 1
}
}
// circuit-building loop
gwire, err := dialer.Dial(Old2New(slc[0].Address))
if err != nil {
return nil, err
}
wire, err := kiss.TransportHandshake(kiss.GenerateDHKeys(),
gwire, pubkey_checker(slc[0].PublicKey))
if err != nil {
gwire.Close()
return nil, err
}
for _, ele := range slc[1:] {
kilog.Debug("Connecting to node %v...", string([]byte(ele.PublicKey)[:10]))
// extend wire
_, err = wire.Write(append([]byte{byte(len(ele.PublicKey))}, ele.PublicKey...))
if err != nil {
gwire.Close()
return nil, err
}
verifier := pubkey_checker(ele.PublicKey)
// at this point wire is raw (well unobfs) connection to next
wire, err = kiss.TransportHandshake(kiss.GenerateDHKeys(), wire, verifier)
if err != nil {
kilog.Debug("Died when transport at %s", ele.PublicKey)
gwire.Close()
return nil, err
}
kilog.Debug("Connected to node %v!", string([]byte(ele.PublicKey)[:10]))
}
_, err = wire.Write([]byte{byte(subchannel)})
if err != nil {
gwire.Close()
return nil, err
}
kilog.Debug("Opened subchannel %d", subchannel)
return wire, nil
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:49,代码来源:builder.go
示例9: make_icom_ctx
func make_icom_ctx(underlying io.ReadWriteCloser, is_server bool,
do_junk bool, PAUSELIM int) *icom_ctx {
ctx := new(icom_ctx)
ctx.is_dead = false
ctx.underlying = underlying
ctx.our_srv = VSListen()
ctx.write_ch = make(chan icom_msg)
// Killswitch is closed when the entire ctx should be abandoned.
killswitch := make(chan bool)
ctx.killswitch = killswitch
var _ks_exec sync.Once
KILL := func() {
_ks_exec.Do(func() {
kilog.Debug("Killswitching!")
ctx.underlying.Close()
ctx.is_dead = true
close(killswitch)
close(ctx.our_srv.vs_ch)
})
}
// Run the main thing
go run_icom_ctx(ctx, KILL, is_server, do_junk, PAUSELIM)
return ctx
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:27,代码来源:make_icom.go
示例10: HandleServer
func HandleServer(conn io.ReadWriteCloser) {
defer conn.Close()
// Read 1 byte command + 40 bytes key
line := make([]byte, 41)
_, err := io.ReadFull(conn, line)
if err != nil {
return
}
// Switch on command
switch line[0] {
case 0x00:
// This is an upload
// We get contents first
buff := new(bytes.Buffer)
_, err := io.Copy(buff, conn)
if err != nil {
kilog.Debug("DHT: Client died while uploading value: %s", err.Error())
return
}
key := dhtkey(kiss.KeyedHash(buff.Bytes(), hashConst)
}
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:25,代码来源:server.go
示例11: socksConnectIP
func socksConnectIP(proxy *net.TCPAddr,
remote *net.TCPAddr) (toret io.ReadWriteCloser, err error) {
conn, err := socksBeginConn(proxy)
if err != nil {
return
}
// Connection request
// 0x05 0x01 0x00 0x01 0x## 0x## 0x## 0x## 0x$$ 0x$$
// VERS TCP RESV IPv4 IP01 IP02 IP03 IP04 PT01 PT02
req := []byte{0x05, 0x01, 0x00, 0x01,
remote.IP[0], remote.IP[1], remote.IP[2], remote.IP[3],
byte(remote.Port / 256), byte(remote.Port % 256)}
_, err = conn.Write(req)
if err != nil {
return
}
kilog.Debug("socks5: --> IP connection request (%v)", remote.IP)
// Server response
// 0x05 0x%% 0x00 0x01 0x## 0x## 0x## 0x## 0x$$ 0x$$
// VERS RESP RESV ...
resp := make([]byte, 10)
_, err = io.ReadFull(conn, resp)
if err != nil {
return
}
return socksParseResponse(resp, conn)
}
开发者ID:ProjectNiwl,项目名称:danasi,代码行数:27,代码来源:socksConnect.go
示例12: connAmb
func (sg *servGroup) connAmb(i int) (*kiricom.ServerCtx, error) {
nonce := make([]byte, 8)
binary.BigEndian.PutUint64(nonce, uint64(i))
hash := natrium.SecureHash(sg.aidee.PublicKey(), nonce)
kilog.Debug("serv: building circuit %v -> %x for %v", i, hash, sg.aidee.PublicKey())
var tgt directory.ChordKey
tgt.FromBytes(hash)
// build circuit to each and every one of them
thingy, err := buildCirc(tgt)
if err != nil {
//thingy.Destroy()
return nil, err
}
haha, err := thingy.RegAmbassador(sg.aidee.PublicKey())
if err != nil {
thingy.Destroy()
if err == core2core.ErrRejectedReq {
kilog.Warning("serv: circuit number %v for %v rejected", i, sg.aidee.PublicKey())
return nil, err
} else {
return nil, err
}
}
return haha, nil
}
开发者ID:ProjectNiwl,项目名称:sagiri,代码行数:27,代码来源:servGroup.go
示例13: destroy
func (cc *commonCtx) destroy(msg error) {
cc.once.Do(func() {
close(cc.deadch)
go cc.carrier.Close()
cc.err = msg
kilog.Debug("kiricom: commonCtx dying due to %v", msg.Error())
})
}
开发者ID:ProjectNiwl,项目名称:sagiri,代码行数:8,代码来源:commonCtx.go
示例14: runAmbass
func (sg *servGroup) runAmbass(i int, ctx *kiricom.ServerCtx) {
for {
client, err := ctx.Accept()
if err != nil {
kilog.Debug("serv: ambassador %v for %v dying due to %v, trying to resurrect", i, sg.aidee.PublicKey(), err.Error())
go sg.revAmbass(i)
return
}
select {
case sg.wirech <- client:
kilog.Debug("serv: %v accepted a client from circuit %v", sg.aidee.PublicKey(), i)
case <-sg.deadch:
kilog.Debug("serv: %v closing circuit %v gracefully", sg.aidee.PublicKey(), i)
return
}
}
}
开发者ID:ProjectNiwl,项目名称:sagiri,代码行数:17,代码来源:servGroup.go
示例15: RunMultiplexSOCKSServer
func RunMultiplexSOCKSServer(transport io.ReadWriteCloser) {
ctx := make_icom_ctx(transport, true, false, 2048)
for {
thing, err := ctx.our_srv.Accept()
if err != nil {
return
}
go func() {
defer thing.Close()
addr, err := socks5.ReadRequest(thing)
if err != nil {
return
}
remote, err := net.DialTimeout("tcp", addr, time.Second*20)
if err != nil {
kilog.Debug("Connection to %s failed: %s", addr, err.Error())
e := err.(net.Error)
if e.Timeout() {
socks5.CompleteRequest(0x06, thing)
} else {
socks5.CompleteRequest(0x01, thing)
}
return
}
defer remote.Close()
rlrem := remote
err = socks5.CompleteRequest(0x00, thing)
if err != nil {
return
}
go func() {
defer rlrem.Close()
io.Copy(rlrem, thing)
}()
kilog.Debug("Opened connection to %s", addr)
io.Copy(thing, rlrem)
}()
}
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:39,代码来源:lowinterface.go
示例16: sc_server_handler
func sc_server_handler(_wire net.Conn) (err error) {
defer func() {
if err != nil {
kilog.Debug("sc_server_handler returning err=%s", err.Error())
}
}()
defer _wire.Close()
wire, err := kiss.Obfs3fHandshake(_wire, true)
if err != nil {
//kilog.Debug(err.Error())
return nil
}
return sc_server_real_handler(wire)
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:14,代码来源:subcircuit_server.go
示例17: thrWatchdog
func (cc *commonCtx) thrWatchdog() {
for {
select {
case <-time.After(time.Second * 120):
cc.destroy(errors.New("timeout"))
return
case <-cc.deadch:
return
case <-cc.wdch:
// watchdog is kicked, redo
kilog.Debug("kiricom: watchdog kicked")
}
}
}
开发者ID:ProjectNiwl,项目名称:sagiri,代码行数:14,代码来源:commonCtx.go
示例18: run_stew
func (ctx *stew_ctx) run_stew(is_server bool) {
defer func() {
if x := recover(); x != nil {
kilog.Debug("%v", x)
}
}()
for {
select {
case <-ctx.killswitch:
kilog.Debug("KILLSWITCH signalled for stew layer!")
return
case thing := <-ctx.llctx.ordered_ch:
//kilog.Debug("Received thing with ctr=%d (%v)", thing.seqnum, is_server)
pkt := bytes_to_stew_message(thing.payload)
if pkt.category == m_open && is_server {
remote_addr := string(pkt.payload)
desired_connid := pkt.connid
ctx.lock.Lock()
ctx.conntable[desired_connid] = make(chan stew_message, 256)
ctx.lock.Unlock()
go ctx.attacht_remote(remote_addr, desired_connid)
} else if pkt.category == m_close || pkt.category == m_data || pkt.category == m_more {
ctx.lock.RLock()
ch := ctx.conntable[pkt.connid]
ctx.lock.RUnlock()
if ch == nil {
//kilog.Debug("stew_message with illegal connid received, killing connid")
continue
}
ch <- pkt
} else if pkt.category == m_dns {
// not implemented
} else {
}
}
}
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:37,代码来源:runstew.go
示例19: socksConnectName
func socksConnectName(proxy *net.TCPAddr,
remote string, port int) (toret io.ReadWriteCloser, err error) {
conn, err := socksBeginConn(proxy)
if err != nil {
return
}
if len(remote) >= 256 {
err = errors.New("socks5: name too long")
return
}
//remote = "google.com" // TODO REMOVE
//port = 80
// Connection request
// 0x05 0x01 0x00 0x03 0x$$ .....
// VERS TCP RESV DNS LEN .....
req := []byte{0x05, 0x01, 0x00, 0x03, byte(len(remote))}
req = append(req, []byte(remote)...)
req = append(req, []byte{byte(port / 256), byte(port % 256)}...)
_, err = conn.Write(req)
if err != nil {
return
}
kilog.Debug("socks5: --> name connection request (%v)", remote)
// Read response back
resp := []byte{0, 0, 0, 0, 0} // same length, convenience
_, err = io.ReadFull(conn, resp)
if err != nil {
return
}
kilog.Debug("socks5: <-- final response hdr (len = %v)", resp[4])
io.ReadFull(conn, make([]byte, resp[4]+5))
kilog.Debug("socks5: <-- final response bdy")
return socksParseResponse(resp, conn)
}
开发者ID:ProjectNiwl,项目名称:danasi,代码行数:37,代码来源:socksConnect.go
示例20: attacht_remote
func (ctx *stew_ctx) attacht_remote(remote_addr string, connid int) {
remconn, err := net.Dial("tcp", remote_addr)
if err != nil {
kilog.Debug("attacht_remote failed to connect to %d!", remote_addr)
return
}
xaxa := (remconn).(*net.TCPConn)
xaxa.SetLinger(0)
xaxa.SetNoDelay(true)
defer xaxa.Close()
tunnel_connection(ctx, connid, xaxa)
}
开发者ID:quantum1423-dustbin,项目名称:kirisurf-legacy,代码行数:16,代码来源:stew_handlers.go
注:本文中的github.com/KirisurfProject/kilog.Debug函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论