repo
stringlengths
6
47
file_url
stringlengths
77
269
file_path
stringlengths
5
186
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-07 08:35:43
2026-01-07 08:55:24
truncated
bool
2 classes
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/timer.go
common/signal/timer.go
package signal import ( "context" "sync" "time" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/task" ) type ActivityUpdater interface { Update() } type ActivityTimer struct { sync.RWMutex updated chan struct{} checkTask *task.Periodic onTimeout func() } func (t *Activity...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/notifier.go
common/signal/notifier.go
package signal // Notifier is a utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asynchronously. type Notifier struct { c chan struct{} } // NewNotifier creates a new Notifier. func NewNotifier() *Notifier { return &Notifier{ c: make(chan struc...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/timer_test.go
common/signal/timer_test.go
package signal_test import ( "context" "runtime" "testing" "time" . "github.com/v2fly/v2ray-core/v5/common/signal" ) func TestActivityTimer(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) timer := CancelAfterInactivity(ctx, cancel, time.Second*4) time.Sleep(time.Second * 6) if ctx.Er...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/notifier_test.go
common/signal/notifier_test.go
package signal_test import ( "testing" . "github.com/v2fly/v2ray-core/v5/common/signal" ) func TestNotifierSignal(t *testing.T) { n := NewNotifier() w := n.Wait() n.Signal() select { case <-w: default: t.Fail() } }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/pubsub/pubsub.go
common/signal/pubsub/pubsub.go
package pubsub import ( "errors" "sync" "time" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/signal/done" "github.com/v2fly/v2ray-core/v5/common/task" ) type Subscriber struct { buffer chan interface{} done *done.Instance } func (s *Subscriber) push(msg interface{}) { sel...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/pubsub/pubsub_test.go
common/signal/pubsub/pubsub_test.go
package pubsub_test import ( "testing" . "github.com/v2fly/v2ray-core/v5/common/signal/pubsub" ) func TestPubsub(t *testing.T) { service := NewService() sub := service.Subscribe("a") service.Publish("a", 1) select { case v := <-sub.Wait(): if v != 1 { t.Error("expected subscribed value 1, but got ", v)...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/semaphore/semaphore.go
common/signal/semaphore/semaphore.go
package semaphore // Instance is an implementation of semaphore. type Instance struct { token chan struct{} } // New create a new Semaphore with n permits. func New(n int) *Instance { s := &Instance{ token: make(chan struct{}, n), } for i := 0; i < n; i++ { s.token <- struct{}{} } return s } // Wait return...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/signal/done/done.go
common/signal/done/done.go
package done import ( "sync" ) // Instance is a utility for notifications of something being done. type Instance struct { access sync.Mutex c chan struct{} closed bool } // New returns a new Done. func New() *Instance { return &Instance{ c: make(chan struct{}), } } // Done returns true if Close() is ca...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/task/periodic.go
common/task/periodic.go
package task import ( "sync" "time" ) // Periodic is a task that runs periodically. type Periodic struct { // Interval of the task being run Interval time.Duration // Execute is the task function Execute func() error access sync.Mutex timer *time.Timer running bool } func (t *Periodic) hasClosed() bool ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/task/periodic_test.go
common/task/periodic_test.go
package task_test import ( "sync/atomic" "testing" "time" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/task" ) func TestPeriodicTaskStop(t *testing.T) { var value uint64 task := &Periodic{ Interval: time.Second * 2, Execute: func() error { atomic.AddUint64(&value, 1)...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/task/task_test.go
common/task/task_test.go
package task_test import ( "context" "errors" "strings" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/task" ) func TestExecuteParallel(t *testing.T) { err := Run(context.Background(), func() error { time.Sleep(time.Mill...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/task/task.go
common/task/task.go
package task import ( "context" "github.com/v2fly/v2ray-core/v5/common/signal/semaphore" ) // OnSuccess executes g() after f() returns nil. func OnSuccess(f func() error, g func() error) func() error { return func() error { if err := f(); err != nil { return err } return g() } } // Run executes a list ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/task/common.go
common/task/common.go
package task import "github.com/v2fly/v2ray-core/v5/common" // Close returns a func() that closes v. func Close(v interface{}) func() error { return func() error { return common.Close(v) } }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/dice/dice.go
common/dice/dice.go
// Package dice contains common functions to generate random number. // It also initialize math/rand with the time in seconds at launch time. package dice import ( crand "crypto/rand" "io" "math/big" "math/rand" "time" "github.com/v2fly/v2ray-core/v5/common" ) // Roll returns a non-negative number between 0 (i...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/dice/dice_test.go
common/dice/dice_test.go
package dice_test import ( "math/rand" "testing" . "github.com/v2fly/v2ray-core/v5/common/dice" ) func BenchmarkRoll1(b *testing.B) { for i := 0; i < b.N; i++ { Roll(1) } } func BenchmarkRoll20(b *testing.B) { for i := 0; i < b.N; i++ { Roll(20) } } func BenchmarkIntn1(b *testing.B) { for i := 0; i < b...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/registry/implementation_set.go
common/registry/implementation_set.go
package registry import ( "github.com/golang/protobuf/proto" "github.com/v2fly/v2ray-core/v5/common/protoext" ) //go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen type implementationSet struct { AliasLookup map[string]*implementation } type CustomLoader func(data []byte, loader LoadByAli...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/registry/registry.go
common/registry/registry.go
package registry import ( "bytes" "context" "reflect" "strings" "sync" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" protov2 "google.golang.org/protobuf/proto" "github.com/v2fly/v2ray-core/v5/common/protoext" "github.com/v2fly/v2ray-core/v5/common/protofilter" "github.com/v2fly/v2...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/registry/errors.generated.go
common/registry/errors.generated.go
package registry import "github.com/v2fly/v2ray-core/v5/common/errors" type errPathObjHolder struct{} func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/registry/restrict.go
common/registry/restrict.go
package registry import ( "context" "google.golang.org/protobuf/proto" "github.com/v2fly/v2ray-core/v5/common/protoext" ) const restrictedLoadModeCtx = "restrictedLoadModeCtx" func CreateRestrictedModeContext(ctx context.Context) context.Context { return context.WithValue(ctx, restrictedLoadModeCtx, true) //no...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/windows.go
common/platform/windows.go
//go:build windows // +build windows package platform import "path/filepath" func LineSeparator() string { return "\r\n" } // GetAssetLocation search for `file` in the excutable dir func GetAssetLocation(file string) string { const name = "v2ray.location.asset" assetPath := NewEnvFlag(name).GetValue(getExecutabl...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/platform_test.go
common/platform/platform_test.go
package platform_test import ( "errors" "io/fs" "os" "path/filepath" "runtime" "testing" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/platform" ) func TestNormalizeEnvName(t *testing.T) { cases := []struct { input string output string }{ { input: "a", output:...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/others.go
common/platform/others.go
//go:build !windows // +build !windows package platform import ( "path/filepath" "github.com/adrg/xdg" ) func LineSeparator() string { return "\n" } // GetAssetLocation search for `file` in certain locations func GetAssetLocation(file string) string { const name = "v2ray.location.asset" assetPath := NewEnvFla...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/platform.go
common/platform/platform.go
package platform import ( "os" "path/filepath" "strconv" "strings" ) type EnvFlag struct { Name string AltName string } func NewEnvFlag(name string) EnvFlag { return EnvFlag{ Name: name, AltName: NormalizeEnvName(name), } } func (f EnvFlag) GetValue(defaultValue func() string) string { if v, foun...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/filesystem/file.go
common/platform/filesystem/file.go
package filesystem import ( "io" "os" "path/filepath" "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/platform" "github.com/v2fly/v2ray-core/v5/common/platform/filesystem/fsifce" ) var NewFileSeeker fsifce.FileSeekerFunc = func(path string) (io.ReadSeekCloser, error) { retur...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/filesystem/fsifce/ifce.go
common/platform/filesystem/fsifce/ifce.go
package fsifce import ( "io" "io/fs" ) type FileSeekerFunc func(path string) (io.ReadSeekCloser, error) type FileReaderFunc func(path string) (io.ReadCloser, error) type FileWriterFunc func(path string) (io.WriteCloser, error) type FileReadDirFunc func(path string) ([]fs.DirEntry, error) type FileRemoveFunc fun...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/ctlcmd/attr_other.go
common/platform/ctlcmd/attr_other.go
//go:build !windows // +build !windows package ctlcmd import "syscall" func getSysProcAttr() *syscall.SysProcAttr { return nil }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/securedload/verify.go
common/platform/securedload/verify.go
package securedload type ProtectedLoader interface { VerifyAndLoad(filename string) ([]byte, error) } var knownProtectedLoader map[string]ProtectedLoader func RegisterProtectedLoader(name string, sv ProtectedLoader) { if knownProtectedLoader == nil { knownProtectedLoader = map[string]ProtectedLoader{} } knownP...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/securedload/file.go
common/platform/securedload/file.go
package securedload func GetAssetSecured(name string) ([]byte, error) { var err error for k, v := range knownProtectedLoader { loadedData, errLoad := v.VerifyAndLoad(name) if errLoad == nil { return loadedData, nil } err = newError(k, " is not loading executable file").Base(errLoad) } return nil, err }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/securedload/errors.generated.go
common/platform/securedload/errors.generated.go
package securedload import "github.com/v2fly/v2ray-core/v5/common/errors" type errPathObjHolder struct{} func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/securedload/embedded.go
common/platform/securedload/embedded.go
package securedload const allowedHashes = `SHA256 (!#project==v2fly) = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff SHA256 (!#version==embedded) = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff SHA256 (subscriptions/subscriptionsDefinition.v2flyTemplate) = 3f165dba7de0d7c506fbdff3...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/securedload/securedload.go
common/platform/securedload/securedload.go
package securedload //go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/platform/securedload/embeddedhash.go
common/platform/securedload/embeddedhash.go
package securedload import ( "bytes" "crypto/sha256" "encoding/hex" "path/filepath" "strings" "github.com/v2fly/VSign/insmgr" "github.com/v2fly/VSign/signerVerify" "github.com/v2fly/v2ray-core/v5/common/platform" "github.com/v2fly/v2ray-core/v5/common/platform/filesystem" ) type EmbeddedHashProtectedLoader...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/chunk_test.go
common/crypto/chunk_test.go
package crypto_test import ( "bytes" "io" "testing" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" . "github.com/v2fly/v2ray-core/v5/common/crypto" ) func TestChunkStreamIO(t *testing.T) { cache := bytes.NewBuffer(make([]byte, 0, 8192)) writer := NewChunkStreamWriter(Pla...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/aes.go
common/crypto/aes.go
package crypto import ( "crypto/aes" "crypto/cipher" "github.com/v2fly/v2ray-core/v5/common" ) // NewAesDecryptionStream creates a new AES encryption stream based on given key and IV. // Caller must ensure the length of key and IV is either 16, 24 or 32 bytes. func NewAesDecryptionStream(key []byte, iv []byte) ci...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/errors.generated.go
common/crypto/errors.generated.go
package crypto import "github.com/v2fly/v2ray-core/v5/common/errors" type errPathObjHolder struct{} func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/chacha20.go
common/crypto/chacha20.go
package crypto import ( "crypto/cipher" "github.com/v2fly/v2ray-core/v5/common/crypto/internal" ) // NewChaCha20Stream creates a new Chacha20 encryption/descryption stream based on give key and IV. // Caller must ensure the length of key is 32 bytes, and length of IV is either 8 or 12 bytes. func NewChaCha20Stream...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/io.go
common/crypto/io.go
package crypto import ( "crypto/cipher" "io" "github.com/v2fly/v2ray-core/v5/common/buf" ) type CryptionReader struct { stream cipher.Stream reader io.Reader } func NewCryptionReader(stream cipher.Stream, reader io.Reader) *CryptionReader { return &CryptionReader{ stream: stream, reader: reader, } } fun...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/chacha20_test.go
common/crypto/chacha20_test.go
package crypto_test import ( "crypto/rand" "encoding/hex" "testing" "github.com/google/go-cmp/cmp" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/crypto" ) func mustDecodeHex(s string) []byte { b, err := hex.DecodeString(s) common.Must(err) return b } func TestChaCha20Str...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/crypto.go
common/crypto/crypto.go
// Package crypto provides common crypto libraries for V2Ray. package crypto //go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/benchmark_test.go
common/crypto/benchmark_test.go
package crypto_test import ( "crypto/cipher" "testing" . "github.com/v2fly/v2ray-core/v5/common/crypto" ) const benchSize = 1024 * 1024 func benchmarkStream(b *testing.B, c cipher.Stream) { b.SetBytes(benchSize) input := make([]byte, benchSize) output := make([]byte, benchSize) b.ResetTimer() for i := 0; i ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/auth.go
common/crypto/auth.go
package crypto import ( "crypto/cipher" "crypto/rand" "io" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/bytespool" "github.com/v2fly/v2ray-core/v5/common/errors" "github.com/v2fly/v2ray-core/v5/common/protocol" ) type BytesGenerato...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/chunk.go
common/crypto/chunk.go
package crypto import ( "encoding/binary" "io" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" ) // ChunkSizeDecoder is a utility class to decode size value from bytes. type ChunkSizeDecoder interface { // SizeBytes must be stable, return the same value across all calls Size...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/auth_test.go
common/crypto/auth_test.go
package crypto_test import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/rand" "io" "testing" "github.com/google/go-cmp/cmp" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" . "github.com/v2fly/v2ray-core/v5/common/crypto" "github.com/v2fly/v2ray-core/v5/common/protocol...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/internal/chacha_core_gen.go
common/crypto/internal/chacha_core_gen.go
//go:build generate // +build generate package main import ( "fmt" "log" "os" ) func writeQuarterRound(file *os.File, a, b, c, d int) { add := "x%d+=x%d\n" xor := "x=x%d^x%d\n" rotate := "x%d=(x << %d) | (x >> (32 - %d))\n" fmt.Fprintf(file, add, a, b) fmt.Fprintf(file, xor, d, a) fmt.Fprintf(file, rotate,...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/internal/chacha.go
common/crypto/internal/chacha.go
package internal //go:generate go run chacha_core_gen.go import ( "encoding/binary" ) const ( wordSize = 4 // the size of ChaCha20's words stateSize = 16 // the size of ChaCha20's state, in words blockSize = stateSize * wordSize // the size of ChaCha20's block, in bytes ) t...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/crypto/internal/chacha_core.generated.go
common/crypto/internal/chacha_core.generated.go
package internal import "encoding/binary" func ChaCha20Block(s *[16]uint32, out []byte, rounds int) { x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 := s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], s[12], s[13], s[14], s[15] for i := 0; i < rounds; i += 2 { var x ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_mph.go
common/strmatcher/matchergroup_mph.go
package strmatcher import ( "math/bits" "sort" "strings" "unsafe" ) // PrimeRK is the prime base used in Rabin-Karp algorithm. const PrimeRK = 16777619 // RollingHash calculates the rolling murmurHash of given string based on a provided suffix hash. func RollingHash(hash uint32, input string) uint32 { for i := ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/indexmatcher_mph_test.go
common/strmatcher/indexmatcher_mph_test.go
package strmatcher_test import ( "reflect" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestMphIndexMatcher(t *testing.T) { rules := []struct { Type Type Domain string }{ { Type: Regex, Domain: "apis\\.us$", }, { Type: Su...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchers_test.go
common/strmatcher/matchers_test.go
package strmatcher_test import ( "reflect" "testing" "unsafe" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestMatcher(t *testing.T) { cases := []struct { pattern string mType Type input string output bool }{ { pattern: "v2fly.org", m...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_simple_test.go
common/strmatcher/matchergroup_simple_test.go
package strmatcher_test import ( "reflect" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestSimpleMatcherGroup(t *testing.T) { patterns := []struct { pattern string mType Type }{ { pattern: "v2fly.org", mType: Domain, }, { ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_substr_test.go
common/strmatcher/matchergroup_substr_test.go
package strmatcher_test import ( "reflect" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestSubstrMatcherGroup(t *testing.T) { patterns := []struct { pattern string mType Type }{ { pattern: "apis", mType: Substr, }, { patte...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_domain_test.go
common/strmatcher/matchergroup_domain_test.go
package strmatcher_test import ( "reflect" "testing" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestDomainMatcherGroup(t *testing.T) { patterns := []struct { Pattern string Value uint32 }{ { Pattern: "v2fly.org", Value: 1, }, { Pattern: "google.com", Value: 2, }, ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchers.go
common/strmatcher/matchers.go
package strmatcher import ( "errors" "regexp" "strings" "unicode/utf8" "golang.org/x/net/idna" ) // FullMatcher is an implementation of Matcher. type FullMatcher string func (FullMatcher) Type() Type { return Full } func (m FullMatcher) Pattern() string { return string(m) } func (m FullMatcher) String() st...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_domain.go
common/strmatcher/matchergroup_domain.go
package strmatcher type trieNode struct { values []uint32 children map[string]*trieNode } // DomainMatcherGroup is an implementation of MatcherGroup. // It uses trie to optimize both memory consumption and lookup speed. Trie node is domain label based. type DomainMatcherGroup struct { root *trieNode } func NewD...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_ac_automation_test.go
common/strmatcher/matchergroup_ac_automation_test.go
package strmatcher_test import ( "reflect" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestACAutomatonMatcherGroup(t *testing.T) { cases1 := []struct { pattern string mType Type input string output bool }{ { pattern: "v2fly.org...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/indexmatcher_linear_test.go
common/strmatcher/indexmatcher_linear_test.go
package strmatcher_test import ( "reflect" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) // See https://github.com/v2fly/v2ray-core/issues/92#issuecomment-673238489 func TestLinearIndexMatcher(t *testing.T) { rules := []struct { Type Type Domain s...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/benchmark_indexmatcher_test.go
common/strmatcher/benchmark_indexmatcher_test.go
package strmatcher_test import ( "testing" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func BenchmarkLinearIndexMatcher(b *testing.B) { benchmarkIndexMatcher(b, func() IndexMatcher { return NewLinearIndexMatcher() }) } func BenchmarkMphIndexMatcher(b *testing.B) { benchmarkIndexMatcher(b, func() I...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_mph_test.go
common/strmatcher/matchergroup_mph_test.go
package strmatcher_test import ( "reflect" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestMphMatcherGroup(t *testing.T) { cases1 := []struct { pattern string mType Type input string output bool }{ { pattern: "v2fly.org", mT...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/benchmark_matchers_test.go
common/strmatcher/benchmark_matchers_test.go
package strmatcher_test import ( "strconv" "testing" "github.com/v2fly/v2ray-core/v5/common" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func BenchmarkFullMatcher(b *testing.B) { b.Run("SimpleMatcherGroup------", func(b *testing.B) { benchmarkMatcherType(b, Full, func() MatcherGroup { return new...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/strmatcher.go
common/strmatcher/strmatcher.go
package strmatcher // Type is the type of the matcher. type Type byte const ( // Full is the type of matcher that the input string must exactly equal to the pattern. Full Type = 0 // Domain is the type of matcher that the input string must be a sub-domain or itself of the pattern. Domain Type = 1 // Substr is th...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/indexmatcher_mph.go
common/strmatcher/indexmatcher_mph.go
package strmatcher // A MphIndexMatcher is divided into three parts: // 1. `full` and `domain` patterns are matched by Rabin-Karp algorithm and minimal perfect hash table; // 2. `substr` patterns are matched by ac automaton; // 3. `regex` patterns are matched with the regex library. type MphIndexMatcher struct { coun...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_full.go
common/strmatcher/matchergroup_full.go
package strmatcher // FullMatcherGroup is an implementation of MatcherGroup. // It uses a hash table to facilitate exact match lookup. type FullMatcherGroup struct { matchers map[string][]uint32 } func NewFullMatcherGroup() *FullMatcherGroup { return &FullMatcherGroup{ matchers: make(map[string][]uint32), } } /...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_substr.go
common/strmatcher/matchergroup_substr.go
package strmatcher import ( "sort" "strings" ) // SubstrMatcherGroup is implementation of MatcherGroup, // It is simply implmeneted to comply with the priority specification of Substr matchers. type SubstrMatcherGroup struct { patterns []string values []uint32 } // AddSubstrMatcher implements MatcherGroupForSu...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/indexmatcher_linear.go
common/strmatcher/indexmatcher_linear.go
package strmatcher // LinearIndexMatcher is an implementation of IndexMatcher. type LinearIndexMatcher struct { count uint32 full *FullMatcherGroup domain *DomainMatcherGroup substr *SubstrMatcherGroup regex *SimpleMatcherGroup } func NewLinearIndexMatcher() *LinearIndexMatcher { return new(LinearIndexMatch...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_ac_automation.go
common/strmatcher/matchergroup_ac_automation.go
package strmatcher import ( "container/list" ) const ( acValidCharCount = 39 // aA-zZ (26), 0-9 (10), - (1), . (1), invalid(1) acMatchTypeCount = 3 // Full, Domain and Substr ) type acEdge byte const ( acTrieEdge acEdge = 1 acFailEdge acEdge = 0 ) type acNode struct { next [acValidCharCount]uint32 // EdgeI...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_full_test.go
common/strmatcher/matchergroup_full_test.go
package strmatcher_test import ( "reflect" "testing" . "github.com/v2fly/v2ray-core/v5/common/strmatcher" ) func TestFullMatcherGroup(t *testing.T) { patterns := []struct { Pattern string Value uint32 }{ { Pattern: "v2fly.org", Value: 1, }, { Pattern: "google.com", Value: 2, }, {...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/strmatcher/matchergroup_simple.go
common/strmatcher/matchergroup_simple.go
package strmatcher type matcherEntry struct { matcher Matcher value uint32 } // SimpleMatcherGroup is an implementation of MatcherGroup. // It simply stores all matchers in an array and sequentially matches them. type SimpleMatcherGroup struct { matchers []matcherEntry } // AddMatcher implements MatcherGroupFor...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/peer/latency.go
common/peer/latency.go
package peer import ( "sync" ) type Latency interface { Value() uint64 } type HasLatency interface { ConnectionLatency() Latency HandshakeLatency() Latency } type AverageLatency struct { access sync.Mutex value uint64 } func (al *AverageLatency) Update(newValue uint64) { al.access.Lock() defer al.access.U...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/peer/peer.go
common/peer/peer.go
package peer
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/bytespool/pool.go
common/bytespool/pool.go
package bytespool import "sync" func createAllocFunc(size int32) func() interface{} { return func() interface{} { return make([]byte, size) } } // The following parameters controls the size of buffer pools. // There are numPools pools. Starting from 2k size, the size of each pool is sizeMulti of the previous one...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/time.go
common/protocol/time.go
package protocol import ( "time" "github.com/v2fly/v2ray-core/v5/common/dice" ) type Timestamp int64 type TimestampGenerator func() Timestamp func NowTime() Timestamp { return Timestamp(time.Now().Unix()) } func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator { return func() Timestamp { ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/time_test.go
common/protocol/time_test.go
package protocol_test import ( "testing" "time" . "github.com/v2fly/v2ray-core/v5/common/protocol" ) func TestGenerateRandomInt64InRange(t *testing.T) { base := time.Now().Unix() delta := 100 generator := NewTimestampGenerator(Timestamp(base), delta) for i := 0; i < 100; i++ { val := int64(generator()) i...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/user.pb.go
common/protocol/user.pb.go
package protocol import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" unsafe "unsafe" ) const ( // Verify that this generated code is sufficiently up-to...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/server_picker_test.go
common/protocol/server_picker_test.go
package protocol_test import ( "testing" "time" "github.com/v2fly/v2ray-core/v5/common/net" . "github.com/v2fly/v2ray-core/v5/common/protocol" ) func TestServerList(t *testing.T) { list := NewServerList() list.AddServer(NewServerSpec(net.TCPDestination(net.LocalHostIP, net.Port(1)), AlwaysValid())) if list.Si...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/headers.pb.go
common/protocol/headers.pb.go
package protocol import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.Mi...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/errors.generated.go
common/protocol/errors.generated.go
package protocol import "github.com/v2fly/v2ray-core/v5/common/errors" type errPathObjHolder struct{} func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/server_picker.go
common/protocol/server_picker.go
package protocol import ( "sync" ) type ServerList struct { sync.RWMutex servers []*ServerSpec } func NewServerList() *ServerList { return &ServerList{} } func (sl *ServerList) AddServer(server *ServerSpec) { sl.Lock() defer sl.Unlock() sl.servers = append(sl.servers, server) } func (sl *ServerList) Size()...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/id_test.go
common/protocol/id_test.go
package protocol_test import ( "testing" . "github.com/v2fly/v2ray-core/v5/common/protocol" "github.com/v2fly/v2ray-core/v5/common/uuid" ) func TestIdEquals(t *testing.T) { id1 := NewID(uuid.New()) id2 := NewID(id1.UUID()) if !id1.Equals(id2) { t.Error("expected id1 to equal id2, but actually not") } if ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/protocol.go
common/protocol/protocol.go
package protocol import ( "errors" ) //go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen var ErrProtoNeedMoreData = errors.New("protocol matches, but need more data to complete sniffing")
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/server_spec.go
common/protocol/server_spec.go
package protocol import ( "sync" "time" "github.com/v2fly/v2ray-core/v5/common/dice" "github.com/v2fly/v2ray-core/v5/common/net" ) type ValidationStrategy interface { IsValid() bool Invalidate() } type alwaysValidStrategy struct{} func AlwaysValid() ValidationStrategy { return alwaysValidStrategy{} } func ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/id.go
common/protocol/id.go
package protocol import ( "crypto/hmac" "crypto/md5" "hash" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/uuid" ) const ( IDBytesLen = 16 ) type IDHash func(key []byte) hash.Hash func DefaultIDHash(key []byte) hash.Hash { return hmac.New(md5.New, key) } // The ID of en enti...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/server_spec_test.go
common/protocol/server_spec_test.go
package protocol_test import ( "strings" "testing" "time" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/net" . "github.com/v2fly/v2ray-core/v5/common/protocol" "github.com/v2fly/v2ray-core/v5/common/uuid" "github.com/v2fly/v2ray-core/v5/proxy/vmess" ) func TestAlwaysValidStra...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/payload.go
common/protocol/payload.go
package protocol type TransferType byte const ( TransferTypeStream TransferType = 0 TransferTypePacket TransferType = 1 ) type AddressType byte const ( AddressTypeIPv4 AddressType = 1 AddressTypeDomain AddressType = 2 AddressTypeIPv6 AddressType = 3 )
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/address_test.go
common/protocol/address_test.go
package protocol_test import ( "bytes" "testing" "github.com/google/go-cmp/cmp" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/net" . "github.com/v2fly/v2ray-core/v5/common/protocol" ) func TestAddressReading(t *testing.T) { data :=...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/context.go
common/protocol/context.go
package protocol import ( "context" ) type key int const ( requestKey key = iota ) func ContextWithRequestHeader(ctx context.Context, request *RequestHeader) context.Context { return context.WithValue(ctx, requestKey, request) } func RequestHeaderFromContext(ctx context.Context) *RequestHeader { request := ctx...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/user.go
common/protocol/user.go
package protocol import "github.com/v2fly/v2ray-core/v5/common/serial" func (u *User) GetTypedAccount() (Account, error) { if u.GetAccount() == nil { return nil, newError("Account missing").AtWarning() } rawAccount, err := serial.GetInstanceOf(u.Account) if err != nil { return nil, err } if asAccount, ok :...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/server_spec.pb.go
common/protocol/server_spec.pb.go
package protocol import ( net "github.com/v2fly/v2ray-core/v5/common/net" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" ) const ( // Verify that this generated code is sufficiently up-to-date...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/address.go
common/protocol/address.go
package protocol import ( "io" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/net" "github.com/v2fly/v2ray-core/v5/common/serial" ) type AddressOption func(*option) func PortThenAddress() AddressOption { return func(p *option) { p.p...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/account.go
common/protocol/account.go
package protocol // Account is a user identity used for authentication. type Account interface { Equals(Account) bool } // AsAccount is an object can be converted into account. type AsAccount interface { AsAccount() (Account, error) }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/headers.go
common/protocol/headers.go
package protocol import ( "runtime" "golang.org/x/sys/cpu" "github.com/v2fly/v2ray-core/v5/common/bitmask" "github.com/v2fly/v2ray-core/v5/common/net" "github.com/v2fly/v2ray-core/v5/common/uuid" ) // RequestCommand is a custom command in a proxy request. type RequestCommand byte const ( RequestCommandTCP = ...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/quic/sniff.go
common/protocol/quic/sniff.go
package quic import ( "crypto" "crypto/aes" "crypto/tls" "encoding/binary" "io" "github.com/quic-go/quic-go/quicvarint" "golang.org/x/crypto/hkdf" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/errors" "github.com/v2fly/v2ray-core...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/quic/cipher_suite.go
common/protocol/quic/cipher_suite.go
package quic import ( "crypto" "crypto/cipher" _ "crypto/tls" _ "unsafe" ) // copied from github.com/quic-go/quic-go/internal/qtls/cipher_suite_go121.go type cipherSuiteTLS13 struct { ID uint16 KeyLen int AEAD func(key, fixedNonce []byte) cipher.AEAD Hash crypto.Hash } // github.com/quic-go/quic-go/...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/quic/sniff_test.go
common/protocol/quic/sniff_test.go
package quic_test import ( "encoding/hex" "errors" "testing" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/protocol" "github.com/v2fly/v2ray-core/v5/common/protocol/quic" ) func TestSniffQUIC(t *testing.T) { pkt, err := hex.DecodeString("cd0000000108f1fb7bcc78aa5e7203a8f864004...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
true
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/tls/sniff.go
common/protocol/tls/sniff.go
package tls import ( "encoding/binary" "errors" "strings" "github.com/v2fly/v2ray-core/v5/common" ) type SniffHeader struct { domain string } func (h *SniffHeader) Protocol() string { return "tls" } func (h *SniffHeader) Domain() string { return h.domain } var ( errNotTLS = errors.New("not TLS hea...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/tls/sniff_test.go
common/protocol/tls/sniff_test.go
package tls_test import ( "testing" . "github.com/v2fly/v2ray-core/v5/common/protocol/tls" ) func TestTLSHeaders(t *testing.T) { cases := []struct { input []byte domain string err bool }{ { input: []byte{ 0x16, 0x03, 0x01, 0x00, 0xc8, 0x01, 0x00, 0x00, 0xc4, 0x03, 0x03, 0x1a, 0xac, 0xb2, 0...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/tls/cert/cert_test.go
common/protocol/tls/cert/cert_test.go
package cert import ( "context" "crypto/x509" "encoding/json" "os" "strings" "testing" "time" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/task" ) func TestGenerate(t *testing.T) { err := generate(nil, true, true, "ca") if err != nil { t.Fatal(err) } } func generate(d...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/tls/cert/errors.generated.go
common/protocol/tls/cert/errors.generated.go
package cert import "github.com/v2fly/v2ray-core/v5/common/errors" type errPathObjHolder struct{} func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/tls/cert/privateKey.go
common/protocol/tls/cert/privateKey.go
package cert import ( "crypto/x509/pkix" "encoding/asn1" "math/big" ) type ecPrivateKey struct { Version int PrivateKey []byte NamedCurveOID asn1.ObjectIdentifier `asn1:"optional,explicit,tag:0"` PublicKey asn1.BitString `asn1:"optional,explicit,tag:1"` } type pkcs8 struct { Version in...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/tls/cert/cert.go
common/protocol/tls/cert/cert.go
package cert import ( "crypto/ecdsa" "crypto/ed25519" "crypto/elliptic" "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/asn1" "encoding/pem" "math/big" "time" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/net" ) //go:generate go run github.com/v2fly/v2ray-core/v5/commo...
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false
v2fly/v2ray-core
https://github.com/v2fly/v2ray-core/blob/b2c3b2506695d872162baeed95c9525fbfdbfda0/common/protocol/udp/packet.go
common/protocol/udp/packet.go
package udp import ( "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/net" ) // Packet is a UDP packet together with its source and destination address. type Packet struct { Payload *buf.Buffer Source net.Destination Target net.Destination }
go
MIT
b2c3b2506695d872162baeed95c9525fbfdbfda0
2026-01-07T08:36:12.135351Z
false