mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-08 05:59:20 +02:00
Move some log from stdout to ray log
This commit is contained in:
parent
f86fe6f91a
commit
d24a636c75
|
@ -0,0 +1,9 @@
|
||||||
|
package xudp
|
||||||
|
|
||||||
|
import "github.com/xtls/xray-core/common/errors"
|
||||||
|
|
||||||
|
type errPathObjHolder struct{}
|
||||||
|
|
||||||
|
func newError(values ...interface{}) *errors.Error {
|
||||||
|
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ func GetGlobalID(ctx context.Context) (globalID [8]byte) {
|
||||||
h.Write([]byte(inbound.Source.String()))
|
h.Write([]byte(inbound.Source.String()))
|
||||||
copy(globalID[:], h.Sum(nil))
|
copy(globalID[:], h.Sum(nil))
|
||||||
if Show {
|
if Show {
|
||||||
fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID)
|
newError(fmt.Sprintf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID)).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/xtls/reality"
|
"github.com/xtls/reality"
|
||||||
"github.com/xtls/xray-core/common/errors"
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
|
"github.com/xtls/xray-core/common/session"
|
||||||
"github.com/xtls/xray-core/core"
|
"github.com/xtls/xray-core/core"
|
||||||
"github.com/xtls/xray-core/transport/internet/tls"
|
"github.com/xtls/xray-core/transport/internet/tls"
|
||||||
"golang.org/x/crypto/chacha20poly1305"
|
"golang.org/x/crypto/chacha20poly1305"
|
||||||
|
@ -133,7 +134,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
|
||||||
binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix()))
|
binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix()))
|
||||||
copy(hello.SessionId[8:], config.ShortId)
|
copy(hello.SessionId[8:], config.ShortId)
|
||||||
if config.Show {
|
if config.Show {
|
||||||
fmt.Printf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16])
|
newError(fmt.Sprintf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16])).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
publicKey, _ := ecdh.X25519().NewPublicKey(config.PublicKey)
|
publicKey, _ := ecdh.X25519().NewPublicKey(config.PublicKey)
|
||||||
uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey)
|
uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey)
|
||||||
|
@ -151,7 +152,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
|
||||||
aead, _ = chacha20poly1305.New(uConn.AuthKey)
|
aead, _ = chacha20poly1305.New(uConn.AuthKey)
|
||||||
}
|
}
|
||||||
if config.Show {
|
if config.Show {
|
||||||
fmt.Printf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\tAEAD: %T\n", localAddr, uConn.AuthKey[:16], aead)
|
newError(fmt.Sprintf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\tAEAD: %T\n", localAddr, uConn.AuthKey[:16], aead)).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
aead.Seal(hello.SessionId[:0], hello.Random[20:], hello.SessionId[:16], hello.Raw)
|
aead.Seal(hello.SessionId[:0], hello.Random[20:], hello.SessionId[:16], hello.Raw)
|
||||||
copy(hello.Raw[39:], hello.SessionId)
|
copy(hello.Raw[39:], hello.SessionId)
|
||||||
|
@ -160,14 +161,14 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if config.Show {
|
if config.Show {
|
||||||
fmt.Printf("REALITY localAddr: %v\tuConn.Verified: %v\n", localAddr, uConn.Verified)
|
newError(fmt.Sprintf("REALITY localAddr: %v\tuConn.Verified: %v\n", localAddr, uConn.Verified)).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
if !uConn.Verified {
|
if !uConn.Verified {
|
||||||
go func() {
|
go func() {
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Transport: &http2.Transport{
|
Transport: &http2.Transport{
|
||||||
DialTLSContext: func(ctx context.Context, network, addr string, cfg *gotls.Config) (net.Conn, error) {
|
DialTLSContext: func(ctx context.Context, network, addr string, cfg *gotls.Config) (net.Conn, error) {
|
||||||
fmt.Printf("REALITY localAddr: %v\tDialTLSContext\n", localAddr)
|
newError(fmt.Sprintf("REALITY localAddr: %v\tDialTLSContext\n", localAddr)).WriteToLog(session.ExportIDToError(ctx))
|
||||||
return uConn, nil
|
return uConn, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -201,7 +202,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", fingerprint.Client) // TODO: User-Agent map
|
req.Header.Set("User-Agent", fingerprint.Client) // TODO: User-Agent map
|
||||||
if first && config.Show {
|
if first && config.Show {
|
||||||
fmt.Printf("REALITY localAddr: %v\treq.UserAgent(): %v\n", localAddr, req.UserAgent())
|
newError(fmt.Sprintf("REALITY localAddr: %v\treq.UserAgent(): %v\n", localAddr, req.UserAgent())).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
times := 1
|
times := 1
|
||||||
if !first {
|
if !first {
|
||||||
|
@ -228,9 +229,9 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
|
||||||
}
|
}
|
||||||
req.URL.Path = getPathLocked(paths)
|
req.URL.Path = getPathLocked(paths)
|
||||||
if config.Show {
|
if config.Show {
|
||||||
fmt.Printf("REALITY localAddr: %v\treq.Referer(): %v\n", localAddr, req.Referer())
|
newError(fmt.Sprintf("REALITY localAddr: %v\treq.Referer(): %v\n", localAddr, req.Referer())).WriteToLog(session.ExportIDToError(ctx))
|
||||||
fmt.Printf("REALITY localAddr: %v\tlen(body): %v\n", localAddr, len(body))
|
newError(fmt.Sprintf("REALITY localAddr: %v\tlen(body): %v\n", localAddr, len(body))).WriteToLog(session.ExportIDToError(ctx))
|
||||||
fmt.Printf("REALITY localAddr: %v\tlen(paths): %v\n", localAddr, len(paths))
|
newError(fmt.Sprintf("REALITY localAddr: %v\tlen(paths): %v\n", localAddr, len(paths))).WriteToLog(session.ExportIDToError(ctx))
|
||||||
}
|
}
|
||||||
maps.Unlock()
|
maps.Unlock()
|
||||||
if !first {
|
if !first {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
gonet "net"
|
gonet "net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -34,7 +33,7 @@ func init() {
|
||||||
if conn, err := upgrader.Upgrade(w, r, nil); err == nil {
|
if conn, err := upgrader.Upgrade(w, r, nil); err == nil {
|
||||||
conns <- conn
|
conns <- conn
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("unexpected error")
|
newError("Browser dialer http upgrade unexpected error").AtError().WriteToLog()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
w.Write(webpage)
|
w.Write(webpage)
|
||||||
|
|
Loading…
Reference in New Issue