本文整理匯總了Golang中github.com/Lafeng/deblocus/golang/glog.Warningln函數的典型用法代碼示例。如果您正苦於以下問題:Golang Warningln函數的具體用法?Golang Warningln怎麽用?Golang Warningln使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Warningln函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: bestSend
func (p *multiplexer) bestSend(data []byte, action_desc string) bool {
var buf = make([]byte, FRAME_HEADER_LEN+len(data))
_frame(buf, FRAME_ACTION_TOKENS, 0, data)
var tun *Conn
for i := 1; i <= 3; i++ {
if p.status < 0 /* MUX_CLOSED */ || p.pool == nil {
if log.V(4) {
log.Warningln("abandon sending data of", action_desc)
}
break
}
tun = p.pool.Select()
if tun != nil {
if tunWrite1(tun, buf) == nil {
return true
}
} else {
time.Sleep(time.Millisecond * 200 * time.Duration(i))
}
}
if log.V(3) {
log.Warningln("failed to send data of", action_desc)
}
return false
}
示例2: initialNegotiation
func (c *Client) initialNegotiation() (tun *Conn) {
var newParams = new(tunParams)
var err error
tun, err = c.nego.negotiate(newParams)
if err != nil {
if log.V(1) == true || DEBUG {
log.Errorf("Connection failed %s, Error: %s. Retry after %s",
c.nego.RemoteName(), err, RETRY_INTERVAL)
} else {
log.Errorf("Connection failed %s. Retry after %s",
c.nego.RemoteName(), RETRY_INTERVAL)
}
if strings.Contains(err.Error(), "closed") {
log.Warningln(string(bytes.Repeat([]byte{'+'}, 30)))
log.Warningln("Maybe your clock is inaccurate, or your client credential is invalid.")
log.Warningln(string(bytes.Repeat([]byte{'+'}, 30)))
os.Exit(2)
}
return nil
}
c.params = newParams
c.token = newParams.token
tun.identifier = c.nego.RemoteName()
log.Infof("Login to the gateway %s successfully", tun.identifier)
return
}
示例3: ClientServe
func (c *Client) ClientServe(conn net.Conn) {
var done bool
defer func() {
if e := recover(); e != nil {
log.Warningln(e)
}
if !done {
SafeClose(conn)
}
}()
reqNum := atomic.AddInt32(&c.reqCnt, 1)
pbConn := NewPushbackInputStream(conn)
proto, e := detectProtocol(pbConn)
if e != nil {
// chrome will make some advance connections and then aborted
// cause a EOF
if e != io.EOF && e != io.ErrUnexpectedEOF {
log.Warningln(e)
}
return
}
switch proto {
case REQ_PROT_SOCKS5:
s5 := s5Handler{conn: pbConn}
s5.handshake()
if !s5.handshakeResponse() {
literalTarget := s5.parseRequest()
if !s5.finalResponse() {
c.mux.HandleRequest("SOCKS5", conn, literalTarget)
done = true
}
}
case REQ_PROT_HTTP:
prot, literalTarget := httpProxyHandshake(pbConn)
if prot == REQ_PROT_HTTP { // plain http
c.mux.HandleRequest("HTTP", pbConn, literalTarget)
} else { // http tunnel
c.mux.HandleRequest("HTTP/T", conn, literalTarget)
}
done = true
default:
log.Warningln("unrecognized request from", conn.RemoteAddr())
time.Sleep(REST_INTERVAL)
}
// client setSeed at every 32 req
if reqNum&0x1f == 0x1f {
myRand.setSeed(0)
}
}
示例4: getToken
func (c *Client) getToken() ([]byte, error) {
c.lock.Lock()
var tlen = len(c.token) / TKSZ
if tlen <= TOKENS_FLOOR {
c.asyncRequestTokens()
}
for len(c.token) < TKSZ {
// release lock for waiting of pendingTK()
c.lock.Unlock()
log.Warningln("Waiting for token. Maybe the requests are coming too fast.")
if !c.pendingTK.acquire(RETRY_INTERVAL * 2) {
return nil, ERR_REQ_TK_TIMEOUT
}
if atomic.LoadInt32(&c.state) < CLT_WORKING {
return nil, ERR_REQ_TK_ABORTED
}
// recover lock status
c.lock.Lock()
}
var token = c.token[:TKSZ]
c.token = c.token[TKSZ:]
// finally release
c.lock.Unlock()
return token, nil
}
示例5: dataSession
func (nego *d5SNegotiation) dataSession(hConn *hashedConn, buf []byte) (session *Session, err error) {
token := buf[:TKSZ]
if session := nego.sessionMgr.take(token); session != nil {
session.identifyConn(hConn.Conn)
nego.tokenBuf = buf
return session, DATATUN_SESSION
}
log.Warningln("Incorrect token from", hConn.RemoteAddr())
return nil, VALIDATION_FAILED
}
示例6: bestSend
func (p *multiplexer) bestSend(data []byte, action_desc string) bool {
var buf = make([]byte, FRAME_HEADER_LEN+len(data))
pack(buf, FRAME_ACTION_TOKENS, 0, data)
for i := 1; i <= 3; i++ {
if atomic.LoadInt32(&p.status) < 0 /* MUX_CLOSED */ || p.pool == nil {
log.Warningln("abandon sending data of", action_desc)
break
}
tun := p.pool.Select()
if tun != nil {
if frameWriteBuffer(tun, buf) == nil {
return true
}
} else {
time.Sleep(time.Millisecond * 200 * time.Duration(i))
}
}
log.Warningln("failed to send data of", action_desc)
return false
}
示例7: ClientServe
func (c *Client) ClientServe(conn net.Conn) {
var done bool
defer func() {
if e := recover(); e != nil {
log.Warningln(e)
}
if !done {
SafeClose(conn)
}
}()
pbConn := NewPushbackInputStream(conn)
switch detectProtocol(pbConn) {
case REQ_PROT_SOCKS5:
s5 := S5Step1{conn: pbConn}
s5.Handshake()
if !s5.HandshakeAck() {
literalTarget := s5.parseSocks5Request()
if !s5.respondSocks5() {
c.mux.HandleRequest("SOCKS5", conn, literalTarget)
done = true
}
}
case REQ_PROT_HTTP:
prot, literalTarget := httpProxyHandshake(pbConn)
if prot == REQ_PROT_HTTP { // plain http
c.mux.HandleRequest("HTTP", pbConn, literalTarget)
} else { // http tunnel
c.mux.HandleRequest("HTTP/T", conn, literalTarget)
}
done = true
default:
log.Warningln("unrecognized request from", conn.RemoteAddr())
time.Sleep(REST_INTERVAL)
}
}
示例8: handshakeResponse
// step1 response
// return: True=Denied
func (s *s5Handler) handshakeResponse() bool {
msg := []byte{5, 0}
if s.err != nil {
// handshake error feedback
log.Warningln(s.err)
if ex, y := s.err.(*exception.Exception); y {
msg[1] = byte(ex.Code())
} else {
msg[1] = 0xff
}
setWTimeout(s.conn)
s.conn.Write(msg)
return true
}
// accept
setWTimeout(s.conn)
_, err := s.conn.Write(msg)
if err != nil {
log.Warningln(err)
return true
}
return false
}
示例9: handshakeSession
// new connection
func (n *dbcSerNego) handshakeSession(hConn *hashedConn) (session *Session, err error) {
defer func() {
// free ibHash
n.ibHash = nil
if e, y := exception.ErrorOf(recover()); y {
log.Warningln("handshake error", e)
err = e
}
}()
var skey = n.verifyThenDHExchange(hConn)
var cf = NewCipherFactory(n.Cipher, skey)
hConn.cipher = cf.InitCipher(n.ibHash)
session = NewSession(hConn.Conn, cf, n)
n.isNewSession = true
n.respondTestWithToken(hConn, session)
return
}
示例10: dataSession
// quick resume session
func (n *dbcSerNego) dataSession(hConn *hashedConn) (session *Session, err error) {
token := make([]byte, TKSZ)
setRTimeout(hConn)
nr, err := hConn.Read(token)
// read buf ok
if nr == len(token) && err == nil {
// check token ok
if session := n.sessionMgr.take(token); session != nil {
// init cipher of new connection
hConn.cipher = session.cipherFactory.InitCipher(token)
// check and set identify
session.identifyConn(hConn.Conn)
return session, nil
}
}
log.Warningln("Incorrect token from", n.clientAddr, nvl(err, NULL))
return nil, VALIDATION_FAILED
}
示例11: CatchException
func CatchException(e interface{}) bool {
if e != nil {
if s, y := e.(string); y {
log.Warningln(s)
} else if ex, y := e.(*Exception); y && ex.warning {
log.Errorln(ex.msg)
return true
} else {
log.Errorln(e)
}
if DEBUG || bool(log.V(3)) {
buf := make([]byte, 1600)
n := runtime.Stack(buf, false)
log.DirectPrintln(string(buf[:n]))
}
return true
}
return false
}
示例12: Handshake
func (s *S5Step1) Handshake() {
var buf = make([]byte, 2)
_, err := io.ReadFull(s.conn, buf)
if err != nil {
s.err = INVALID_SOCKS5_HEADER.Apply(err)
return
}
ver, nmethods := buf[0], int(buf[1])
if ver != SOCKS5_VER || nmethods < 1 {
s.err = INVALID_SOCKS5_HEADER.Apply(fmt.Sprintf("[% x]", buf[:2]))
return
}
buf = make([]byte, nmethods+1) // consider method non-00
n, err := io.ReadAtLeast(s.conn, buf, nmethods)
if err != nil || n != nmethods {
s.err = INVALID_SOCKS5_HEADER
log.Warningln("invalid socks5 header:", hex.EncodeToString(buf))
}
}
示例13: TunnelServe
func (t *Server) TunnelServe(conn *net.TCPConn) {
fconn := NewConnWithHash(conn)
defer func() {
fconn.FreeHash()
ex.CatchException(recover())
}()
nego := &d5SNegotiation{Server: t}
session, err := nego.negotiate(fconn)
if err == nil || err == DATATUN_SESSION { // dataTunnel
go session.DataTunServe(fconn.Conn, nego.tokenBuf)
} else {
log.Warningln("Close abnormal connection from", conn.RemoteAddr(), err)
SafeClose(conn)
if session != nil {
t.sessionMgr.clearTokens(session)
}
}
}
示例14: initialNegotiation
func (c *Client) initialNegotiation() (tun *Conn) {
var tp = new(tunParams)
var err error
tun, err = c.nego.negotiate(tp)
if err != nil {
log.Errorf("Failed to connect %s, Retry after %s\n", c.nego.RemoteName(), RETRY_INTERVAL)
if strings.Contains(err.Error(), "closed") {
log.Warningln("Maybe your clock is inaccurate, or your client credential is invalid.")
os.Exit(2)
}
return nil
}
c.token, c.tp = tp.token, tp
tp.token = nil
tun.identifier = c.nego.RemoteName()
log.Infoln("Login to the gateway", c.nego.RemoteName(), "successfully")
return tun
}
示例15: getToken
func (c *Client) getToken() []byte {
c.lock.Lock()
defer c.lock.Unlock()
var tlen = len(c.token) / TKSZ
if tlen <= TOKENS_FLOOR {
c.requireTokens()
}
for len(c.token) < TKSZ {
log.Warningln("waiting for token. May be the requests are coming too fast.")
if !c.pendingTK.acquire(RETRY_INTERVAL * 2) { // discarded request
panic("Aborted")
}
if atomic.LoadInt32(&c.State) < CLT_WORKING {
panic("Abandon the request by shutdown.")
}
}
var token = c.token[:TKSZ]
c.token = c.token[TKSZ:]
return token
}