func (oc *ObfsConn) Read(b []byte) (n int, err error) {
    // first read obfs content upon connection
    if !oc.ObfsInfo.ObfsHeaderRecved {
        n, err = oc.Conn.Read(b)
        oc.ObfsInfo.ObfsHeaderRecved = true
        return n, err
    }
    if oc.Cipher == nil || oc.Cipher.dec == nil {
        err = fmt.Errorf("oc cipher[%p] nullptr or decryptor not init!", oc.Cipher)
        return 0, err
    }
    cipherData := oc.readBuf
    if len(b) > len(cipherData) {
        cipherData = make([]byte, len(b))
    } else {
        cipherData = cipherData[:len(b)]
    }

    n, err = oc.Conn.Read(cipherData)
    if n > 0 {
        oc.decrypt(b[:n], cipherData[:n])
    }
    return
}
// Upon connection accepting, read content exists obfs headers.
Upon connection accepting, read content exists obfs headers.
// Upon connection accepting read content exists obfs headers .
func (oc *ObfsConn) Read(b []byte) (n int, err error) {
    if !oc.ObfsInfo.ObfsHeaderRecved {
        n, err = oc.Conn.Read(b)
        oc.ObfsInfo.ObfsHeaderRecved = true
        return n, err
    }
    if oc.Cipher == nil || oc.Cipher.dec == nil {
        err = fmt.Errorf("oc cipher[%p] nullptr or decryptor not init!", oc.Cipher)
        return 0, err
    }
    cipherData := oc.readBuf
    if len(b) > len(cipherData) {
        cipherData = make([]byte, len(b))
    } else {
        cipherData = cipherData[:len(b)]
    }
    n, err = oc.Conn.Read(cipherData)
    if n > 0 {
        oc.decrypt(b[:n], cipherData[:n])
    }
    return
}
func ( oc * ObfsConn ) Read ( b [ ] byte ) ( n int , err error ) { if ! oc . ObfsInfo . ObfsHeaderRecved { n , err = oc . Conn . Read ( b ) oc . ObfsInfo . ObfsHeaderRecved = true return n , err } if oc . Cipher == nil || oc . Cipher . dec == nil { err = fmt . Errorf ( " " , oc . Cipher ) return 0 , err } cipherData := oc . readBuf if len ( b ) > len ( cipherData ) { cipherData = make ( [ ] byte , len ( b ) ) } else { cipherData = cipherData [ : len ( b ) ] } n , err = oc . Conn . Read ( cipherData ) if n > 0 { oc . decrypt ( b [ : n ] , cipherData [ : n ] ) } return }
Upon connection accepting, read content exists obfs headers.
Upon connection accepting read content exists obfs headers .
// first read obfs content upon connection