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
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/structures/TreeNode_test.go
structures/TreeNode_test.go
package structures import ( "reflect" "testing" "github.com/stretchr/testify/assert" ) var ( // 同一个 TreeNode 的不同表达方式 // 1 // / \ // 2 3 // / \ / \ // 4 5 6 7 LeetCodeOrder = []int{1, 2, 3, 4, 5, 6, 7} preOrder = []int{1, 2, 4, 5, 3, 6, 7} inOrder ...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/structures/Stack.go
structures/Stack.go
package structures // Stack 是用于存放 int 的 栈 type Stack struct { nums []int } // NewStack 返回 *kit.Stack func NewStack() *Stack { return &Stack{nums: []int{}} } // Push 把 n 放入 栈 func (s *Stack) Push(n int) { s.nums = append(s.nums, n) } // Pop 从 s 中取出最后放入 栈 的值 func (s *Stack) Pop() int { res := s.nums[len(s.nums)-1...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/structures/PriorityQueue.go
structures/PriorityQueue.go
package structures // This example demonstrates a priority queue built using the heap interface. import ( "container/heap" ) // entry 是 priorityQueue 中的元素 type entry struct { key string priority int // index 是 entry 在 heap 中的索引号 // entry 加入 Priority Queue 后, Priority 会变化时,很有用 // 如果 entry.priority 一直不变的话,可...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/structures/PriorityQueue_test.go
structures/PriorityQueue_test.go
package structures import ( "container/heap" "testing" "github.com/stretchr/testify/assert" ) func Test_priorityQueue(t *testing.T) { ast := assert.New(t) // Some items and their priorities. items := map[string]int{ "banana": 2, "apple": 1, "pear": 3, } // Create a priority queue, put the items in it, an...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/structures/Heap_test.go
structures/Heap_test.go
package structures import ( "container/heap" "fmt" "testing" "github.com/stretchr/testify/assert" ) func Test_intHeap(t *testing.T) { ast := assert.New(t) ih := new(intHeap) heap.Init(ih) heap.Push(ih, 1) heap.Pop(ih) begin, end := 0, 10 for i := begin; i < end; i++ { heap.Push(ih, i) ast.Equal(0, ...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/structures/NestedInteger.go
structures/NestedInteger.go
package structures // NestedInteger is the interface that allows for creating nested lists. // You should not implement it, or speculate about its implementation type NestedInteger struct { Num int Ns []*NestedInteger } // IsInteger Return true if this NestedInteger holds a single integer, rather than a nested li...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/request.go
ctl/request.go
package main import ( "bytes" "fmt" "io/ioutil" "net/http" "github.com/mozillazg/request" ) const ( // AllProblemURL define AllProblemURL = "https://leetcode.com/api/problems/all/" // QraphqlURL define QraphqlURL = "https://leetcode.com/graphql" // LoginPageURL define LoginPageURL = "https://leetcode.com/...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/error.go
ctl/error.go
package main import ( "fmt" "os" ) const ( // ExitSuccess define ExitSuccess = iota // ExitError define ExitError // ExitBadArgs define ExitBadArgs ) // ExitWithError define func ExitWithError(code int, err error) { fmt.Fprintln(os.Stderr, "Error: ", err) os.Exit(code) }
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/template_render.go
ctl/template_render.go
package main import ( "bytes" "fmt" "html/template" "io/ioutil" "os" m "github.com/halfrost/LeetCode-Go/ctl/models" "github.com/halfrost/LeetCode-Go/ctl/util" ) func makeReadmeFile(mdrows m.Mdrows) { file := "./README.md" os.Remove(file) var b bytes.Buffer tmpl := template.Must(template.New("readme").Pars...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/render.go
ctl/render.go
package main import ( "bufio" "encoding/json" "fmt" "io" "os" "regexp" "sort" "strconv" "strings" m "github.com/halfrost/LeetCode-Go/ctl/models" "github.com/halfrost/LeetCode-Go/ctl/util" "github.com/spf13/cobra" ) var ( chapterTwoList = []string{"Array", "String", "Two Pointers", "Linked List", "Stack"...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/config.go
ctl/config.go
package main import ( "fmt" "log" "github.com/BurntSushi/toml" ) const ( configTOML = "config.toml" ) type config struct { Username string Password string Cookie string CSRFtoken string } func (c config) String() string { return fmt.Sprintf("Username: %s, Password: %s", c.Username, c.Password) } fun...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/rangking.go
ctl/rangking.go
package main import ( "fmt" "strconv" "strings" ) // getRanking 让这个方法优雅一点 func getRanking() int { // 获取网页数据 URL := fmt.Sprintf("https://leetcode.com/%s/", getConfig().Username) data := getRaw(URL) str := string(data) // 通过不断裁剪 str 获取排名信息 fmt.Println(str) i := strings.Index(str, "ng-init") j := i + strings....
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/refresh.go
ctl/refresh.go
package main import ( "github.com/spf13/cobra" ) func newRefresh() *cobra.Command { cmd := &cobra.Command{ Use: "refresh", Short: "Refresh all document", Run: func(cmd *cobra.Command, args []string) { refresh() }, } // cmd.Flags().StringVar(&alias, "alias", "", "alias") // cmd.Flags().StringVar(&app...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/pdf.go
ctl/pdf.go
package main import ( "bufio" "fmt" "io" "io/ioutil" "os" "regexp" "strconv" "strings" "github.com/halfrost/LeetCode-Go/ctl/util" "github.com/spf13/cobra" ) var ( cleanString1 = "{{< columns >}}" cleanString2 = "<--->" cleanString3 = "{{< /columns >}}" cleanString4 = "<img src=\"https://books.halfrost....
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/statistic.go
ctl/statistic.go
package main import ( "sort" m "github.com/halfrost/LeetCode-Go/ctl/models" "github.com/halfrost/LeetCode-Go/ctl/util" ) func statisticalData(problemsMap map[int]m.StatStatusPairs, solutionIds []int) (easyTotal, mediumTotal, hardTotal, optimizingEasy, optimizingMedium, optimizingHard int32, optimizingIds []int) {...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/version.go
ctl/version.go
package main import ( "fmt" "github.com/spf13/cobra" ) var ( version = "v1.0" versionCmd = &cobra.Command{ Use: "version", Short: "Prints the version of tacoctl", Run: func(cmd *cobra.Command, args []string) { fmt.Println("tacoctl version:", version) }, } )
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/command.go
ctl/command.go
package main import ( "fmt" "os" "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ Use: "leetcode-go", Short: "A simple command line client for leetcode-go.", } func execute() { if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(-1) } } func init() { rootCmd.AddCommand( versi...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/main.go
ctl/main.go
package main func main() { execute() }
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/label.go
ctl/label.go
package main import ( "bufio" "errors" "fmt" "io" "io/ioutil" "os" "regexp" "strings" "github.com/halfrost/LeetCode-Go/ctl/util" "github.com/spf13/cobra" ) var ( chapterOneFileOrder = []string{"_index", "Data_Structure", "Algorithm", "Time_Complexity"} chapterOneMenuOrder = []string{"_index", "#关于作者", "D...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/util/util.go
ctl/util/util.go
package util import ( "bufio" "fmt" "io" "io/ioutil" "os" "path/filepath" "sort" "strconv" "strings" ) // LoadSolutionsDir define func LoadSolutionsDir() ([]int, []string, int) { solutionIds, soNames, total := loadFile("../leetcode/") fmt.Printf("读取了 %v 道题的题解,当前目录下有 %v 个文件(可能包含 .DS_Store),目录中有 %v 道题在尝试中\n"...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/models/tagproblem.go
ctl/models/tagproblem.go
package models import ( "encoding/json" "fmt" "strconv" "strings" "github.com/halfrost/LeetCode-Go/ctl/util" ) // Graphql define type Graphql struct { OperationName string `json:"operationName"` Variables struct { TitleSlug string `json:"titleSlug"` } `json:"variables"` Query string `json:"query"` } ...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/models/lcproblems.go
ctl/models/lcproblems.go
package models import ( "fmt" "strings" ) // LeetCodeProblemAll define type LeetCodeProblemAll struct { UserName string `json:"user_name"` NumSolved int32 `json:"num_solved"` NumTotal int32 `json:"num_total"` AcEasy int32 `json:"ac_easy...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/models/user.go
ctl/models/user.go
package models import ( "fmt" ) // UserInfo define type UserInfo struct { UserName string `json:"user_name"` NumSolved int32 `json:"num_solved"` NumTotal int32 `json:"num_total"` AcEasy int32 `json:"ac_easy"` AcMedium int32 `json:"ac_medium"` AcHard int32 ...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/ctl/models/mdrow.go
ctl/models/mdrow.go
package models import ( "fmt" "strings" ) // Mdrow define type Mdrow struct { FrontendQuestionID int32 `json:"question_id"` QuestionTitle string `json:"question__title"` QuestionTitleSlug string `json:"question__title_slug"` SolutionPath string `json:"solution_path"` Acceptance string `jso...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/BIT.go
template/BIT.go
package template // BinaryIndexedTree define type BinaryIndexedTree struct { tree []int capacity int } // Init define func (bit *BinaryIndexedTree) Init(capacity int) { bit.tree, bit.capacity = make([]int, capacity+1), capacity } // Add define func (bit *BinaryIndexedTree) Add(index int, val int) { for ; ind...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/CLRUCache_test.go
template/CLRUCache_test.go
package template import ( "container/list" "math/rand" "strconv" "sync" "testing" "time" "github.com/stretchr/testify/assert" ) func Test_CLRUCache(t *testing.T) { obj := New(2) time.Sleep(150 * time.Millisecond) obj.Put("1", 1) time.Sleep(150 * time.Millisecond) obj.Put("2", 2) time.Sleep(150 * time.Mi...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/LFUCache.go
template/LFUCache.go
package template import "container/list" // LFUCache define type LFUCache struct { nodes map[int]*list.Element lists map[int]*list.List capacity int min int } type node struct { key int value int frequency int } // Constructor define func Constructor(capacity int) LFUCache { return LFUC...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/bucket.go
template/bucket.go
package template import ( "container/list" "sync" ) type bucket struct { sync.RWMutex keys map[string]*list.Element } func (b *bucket) pairCount() int { b.RLock() defer b.RUnlock() return len(b.keys) } func (b *bucket) get(key string) *list.Element { b.RLock() defer b.RUnlock() if el, ok := b.keys[key]; o...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/LRUCache.go
template/LRUCache.go
package template // LRUCache define type LRUCache struct { head, tail *Node keys map[int]*Node capacity int } // Node define type Node struct { key, val int prev, next *Node } // ConstructorLRU define func ConstructorLRU(capacity int) LRUCache { return LRUCache{keys: make(map[int]*Node), capacity: ca...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/UnionFind.go
template/UnionFind.go
package template // UnionFind defind // 路径压缩 + 秩优化 type UnionFind struct { parent, rank []int count int } // Init define func (uf *UnionFind) Init(n int) { uf.count = n uf.parent = make([]int, n) uf.rank = make([]int, n) for i := range uf.parent { uf.parent[i] = i } } // Find define func (uf *UnionFi...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/BIT_test.go
template/BIT_test.go
package template import ( "fmt" "testing" ) func Test_BIT(t *testing.T) { nums, bit := []int{1, 2, 3, 4, 5, 6, 7, 8}, BinaryIndexedTree{} bit.Init(8) fmt.Printf("nums = %v bit = %v\n", nums, bit.tree) // [0 1 3 3 10 5 11 7 36] }
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/CLRUCache.go
template/CLRUCache.go
package template import ( "container/list" "hash/fnv" "sync" ) type command int const ( // MoveToFront define MoveToFront command = iota // PushFront define PushFront // Delete define Delete ) type clear struct { done chan struct{} } // CLRUCache define: High Concurrency LRUCache type CLRUCache struct { ...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
halfrost/LeetCode-Go
https://github.com/halfrost/LeetCode-Go/blob/d78a9e0927a302038992428433d2eb450efd93a2/template/SegmentTree.go
template/SegmentTree.go
package template // SegmentTree define type SegmentTree struct { data, tree, lazy []int left, right int merge func(i, j int) int } // Init define func (st *SegmentTree) Init(nums []int, oper func(i, j int) int) { st.merge = oper data, tree, lazy := make([]int, len(nums)), make([]int, 4*len(nums))...
go
MIT
d78a9e0927a302038992428433d2eb450efd93a2
2026-01-07T08:36:06.754118Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/generate.go
generate.go
//go:generate go run ./internal/ package main func main() {}
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/collector/collector_test.go
pkg/collector/collector_test.go
package collector import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/collector/hydratation" "github.com/traefik/traefik/v3/pkg/config/static" ) func Test_createBody(t *testing.T) { var staticConfiguration static.Configuration err :...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/collector/collector.go
pkg/collector/collector.go
package collector import ( "bytes" "encoding/base64" "encoding/json" "net" "net/http" "strconv" "time" "github.com/mitchellh/hashstructure" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/config/static" "github.com/traefik/traefik/v3/pkg/redactor" "github.com/traefik/traefik/v3/pkg/version"...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/collector/hydratation/hydration.go
pkg/collector/hydratation/hydration.go
package hydratation import ( "fmt" "reflect" "time" "github.com/traefik/paerser/types" ) const ( sliceItemNumber = 2 mapItemNumber = 2 defaultString = "foobar" defaultNumber = 42 defaultBool = true defaultMapKeyPrefix = "name" ) // Hydrate hydrates a configuration. func Hydra...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/tcp/matcher_test.go
pkg/muxer/tcp/matcher_test.go
package tcp import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/tcp" ) func Test_HostSNICatchAll(t *testing.T) { testCases := []struct { desc string rule string isCatchAll bool }{ { desc: "HostSNI(`example.com`)...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/tcp/matcher_v2.go
pkg/muxer/tcp/matcher_v2.go
package tcp import ( "bytes" "errors" "fmt" "regexp" "strconv" "strings" "github.com/go-acme/lego/v4/challenge/tlsalpn01" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/ip" ) var tcpFuncsV2 = map[string]func(*matchersTree, ...string) error{ "ALPN": alpnV2, "ClientIP": clientI...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/tcp/mux_test.go
pkg/muxer/tcp/mux_test.go
package tcp import ( "net" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/tcp" ) func Test_addTCPRoute(t *testing.T) { testCases := []struct { desc string rule string serverName string remoteAddr string proto...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/tcp/matcher.go
pkg/muxer/tcp/matcher.go
package tcp import ( "fmt" "regexp" "strings" "unicode/utf8" "github.com/go-acme/lego/v4/challenge/tlsalpn01" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/ip" ) var tcpFuncs = map[string]func(*matchersTree, ...string) error{ "ALPN": expect1Parameter(alpn), "ClientIP": expect1...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/tcp/matcher_v2_test.go
pkg/muxer/tcp/matcher_v2_test.go
package tcp import ( "fmt" "testing" "github.com/go-acme/lego/v4/challenge/tlsalpn01" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/tcp" ) // All the tests in the suite are a copy of tcp muxer tests on branch v2. // Only the test for route priorit...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/tcp/mux.go
pkg/muxer/tcp/mux.go
package tcp import ( "fmt" "net" "sort" "strings" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/rules" "github.com/traefik/traefik/v3/pkg/tcp" "github.com/traefik/traefik/v3/pkg/types" "github.com/vulcand/predicate" ) // ConnData contains TCP connection metadata. type ConnData struct { ser...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/parser.go
pkg/muxer/http/parser.go
package http import ( "errors" "fmt" "maps" "slices" "strings" "github.com/traefik/traefik/v3/pkg/rules" "github.com/vulcand/predicate" ) type SyntaxParser struct { parsers map[string]*parser } type Options func(map[string]matcherBuilderFuncs) func WithMatcher(syntax, matcherName string, builderFunc func(p...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/matcher_test.go
pkg/muxer/http/matcher_test.go
package http import ( "net/http" "net/http/httptest" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/middlewares/requestdecorator" ) func TestClientIPMatcher(t *testing.T) { testCases := []struct { desc string rule...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/matcher_v2.go
pkg/muxer/http/matcher_v2.go
package http import ( "fmt" "net/http" "strings" "github.com/gorilla/mux" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/ip" "github.com/traefik/traefik/v3/pkg/middlewares/requestdecorator" ) var httpFuncsV2 = matcherBuilderFuncs{ "Host": hostV2, "HostHeader": hostV2, "HostRegex...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/mux_test.go
pkg/muxer/http/mux_test.go
package http import ( "bufio" "bytes" "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/middlewares/requestdecorator" "github.com/traefik/traefik/v3/pkg/testhelpers" ) func TestMuxer(t *testing.T) { testCas...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/matcher.go
pkg/muxer/http/matcher.go
package http import ( "fmt" "net/http" "regexp" "slices" "strings" "unicode/utf8" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/ip" "github.com/traefik/traefik/v3/pkg/middlewares/requestdecorator" ) var httpFuncs = matcherBuilderFuncs{ "ClientIP": expectNParameters(clientIP, 1), "Meth...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/matcher_v2_test.go
pkg/muxer/http/matcher_v2_test.go
package http import ( "net/http" "net/http/httptest" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/middlewares/requestdecorator" "github.com/traefik/traefik/v3/pkg/testhelpers" ) func TestClientIPV2Matcher(t *testing.T) { te...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
true
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/muxer/http/mux.go
pkg/muxer/http/mux.go
package http import ( "context" "errors" "fmt" "net/http" "net/url" "sort" "strings" "github.com/gorilla/mux" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/rules" ) type matcherBuilderFuncs map[string]matcherBuilderFunc type matcherBuilderFunc func(*matchersTree, ...string) error type Ma...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/ocsp.go
pkg/tls/ocsp.go
package tls import ( "bytes" "context" "crypto/x509" "errors" "fmt" "io" "net/http" "time" "github.com/patrickmn/go-cache" "github.com/rs/zerolog/log" "golang.org/x/crypto/ocsp" ) const defaultCacheDuration = 24 * time.Hour type ocspEntry struct { leaf *x509.Certificate issuer *x509.Certifica...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/cipher.go
pkg/tls/cipher.go
package tls import ( "crypto/tls" ) var ( // CipherSuites Map of TLS CipherSuites from crypto/tls // Available CipherSuites defined at https://pkg.go.dev/crypto/tls/#pkg-constants CipherSuites = map[string]uint16{ `TLS_RSA_WITH_RC4_128_SHA`: tls.TLS_RSA_WITH_RC4_128_SHA, `TLS_RSA_WITH_3DE...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/zz_generated.deepcopy.go
pkg/tls/zz_generated.deepcopy.go
//go:build !ignore_autogenerated // +build !ignore_autogenerated /* The MIT License (MIT) Copyright (c) 2016-2020 Containous SAS; 2020-2026 Traefik Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the So...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/tlsmanager.go
pkg/tls/tlsmanager.go
package tls import ( "context" "crypto/tls" "crypto/x509" "errors" "fmt" "hash/fnv" "slices" "strconv" "strings" "sync" "github.com/go-acme/lego/v4/challenge/dns01" "github.com/go-acme/lego/v4/challenge/tlsalpn01" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/observability/logs" "githu...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/ocsp_test.go
pkg/tls/ocsp_test.go
package tls import ( "crypto" "crypto/tls" "io" "net/http" "net/http/httptest" "testing" "time" "github.com/patrickmn/go-cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/crypto/ocsp" ) const certWithOCSPServer = `-----BEGIN CERTIFICATE----- MIIBgjCCASegAwIBAg...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/tlsmanager_test.go
pkg/tls/tlsmanager_test.go
package tls import ( "context" "crypto" "crypto/tls" "crypto/x509" "encoding/pem" "io" "net/http" "net/http/httptest" "testing" "time" "github.com/patrickmn/go-cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/types" "golang.org/x/crypt...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/certificate.go
pkg/tls/certificate.go
package tls import ( "crypto/tls" "crypto/x509" "errors" "fmt" "net/url" "os" "strings" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/types" ) var ( // MinVersion Map of allowed TLS minimum versions. MinVersion = map[string]uint16{ `VersionTLS10`: tls.VersionTLS10, `VersionTLS11`: tls...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/certificate_store_test.go
pkg/tls/certificate_store_test.go
package tls import ( "crypto/tls" "fmt" "strings" "testing" "time" "github.com/patrickmn/go-cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/safe" ) func TestGetBestCertificate(t *testing.T) { // TODO Add tests for defaultCert testCases :...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/version.go
pkg/tls/version.go
package tls import "crypto/tls" // GetVersion returns the normalized TLS version. // Available TLS versions defined at https://pkg.go.dev/crypto/tls/#pkg-constants func GetVersion(connState *tls.ConnectionState) string { switch connState.Version { case tls.VersionTLS10: return "1.0" case tls.VersionTLS11: retu...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/certificate_store.go
pkg/tls/certificate_store.go
package tls import ( "crypto/tls" "fmt" "net" "sort" "strings" "time" "github.com/patrickmn/go-cache" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/safe" ) // CertificateData holds runtime data for runtime TLS certificate handling. type CertificateData struct { Hash string Certific...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/cipher_test.go
pkg/tls/cipher_test.go
package tls import ( "testing" ) func TestCiphersMapsSync(t *testing.T) { for k, v := range CipherSuites { // Following names are legacy aliases. // We do not test for their presence in CipherSuitesReversed switch k { case "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305": ...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/tls.go
pkg/tls/tls.go
package tls import "github.com/traefik/traefik/v3/pkg/types" const certificateHeader = "-----BEGIN CERTIFICATE-----\n" // +k8s:deepcopy-gen=true // ClientAuth defines the parameters of the client authentication part of the TLS connection, if any. type ClientAuth struct { CAFiles []types.FileOrContent `json:"caFile...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tls/generate/generate.go
pkg/tls/generate/generate.go
package generate import ( "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/tls" "crypto/x509" "crypto/x509/pkix" "encoding/hex" "encoding/pem" "fmt" "math/big" "time" ) // DefaultDomain Traefik domain for the default certificate. const DefaultDomain = "TRAEFIK DEFAULT CERT" // DefaultCertificate generat...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/switcher.go
pkg/tcp/switcher.go
package tcp import ( "github.com/traefik/traefik/v3/pkg/safe" ) // HandlerSwitcher is a TCP handler switcher. type HandlerSwitcher struct { router safe.Safe } // ServeTCP forwards the TCP connection to the current active handler. func (s *HandlerSwitcher) ServeTCP(conn WriteCloser) { handler := s.router.Get() h,...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/proxy.go
pkg/tcp/proxy.go
package tcp import ( "errors" "io" "net" "syscall" "time" "github.com/rs/zerolog/log" ) // Proxy forwards a TCP request to a TCP service. type Proxy struct { address string dialer Dialer } // NewProxy creates a new Proxy. func NewProxy(address string, dialer Dialer) (*Proxy, error) { return &Proxy{ addr...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/dialer.go
pkg/tcp/dialer.go
package tcp import ( "context" "crypto/tls" "crypto/x509" "errors" "fmt" "net" "sync" "time" "github.com/pires/go-proxyproto" "github.com/rs/zerolog/log" "github.com/spiffe/go-spiffe/v2/bundle/x509bundle" "github.com/spiffe/go-spiffe/v2/spiffeid" "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" "git...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/chain_test.go
pkg/tcp/chain_test.go
package tcp import ( "net" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) type HandlerTCPFunc func(WriteCloser) // ServeTCP calls f(conn). func (f HandlerTCPFunc) ServeTCP(conn WriteCloser) { f(conn) } // A constructor for middleware // that writes its own "tag"...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/wrr_load_balancer.go
pkg/tcp/wrr_load_balancer.go
package tcp import ( "context" "errors" "sync" "github.com/rs/zerolog/log" ) var errNoServersInPool = errors.New("no servers in the pool") type server struct { Handler name string weight int } // WRRLoadBalancer is a naive RoundRobin load balancer for TCP services. type WRRLoadBalancer struct { // server...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/proxy_test.go
pkg/tcp/proxy_test.go
package tcp import ( "bytes" "io" "net" "testing" "time" "github.com/stretchr/testify/require" ) func TestCloseWrite(t *testing.T) { backendListener, err := net.Listen("tcp", ":0") require.NoError(t, err) go fakeServer(t, backendListener) _, port, err := net.SplitHostPort(backendListener.Addr().String()) ...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/chain.go
pkg/tcp/chain.go
package tcp import ( "errors" ) // Constructor A constructor for a piece of TCP middleware. // Some TCP middleware use this constructor out of the box, // so in most cases you can just pass somepackage.New. type Constructor func(Handler) (Handler, error) // Chain is a chain for TCP handlers. // Chain acts as a list...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/dialer_test.go
pkg/tcp/dialer_test.go
package tcp import ( "bytes" "crypto/rand" "crypto/rsa" "crypto/tls" "crypto/x509" "crypto/x509/pkix" "errors" "io" "math/big" "net" "net/url" "testing" "time" "github.com/pires/go-proxyproto" "github.com/spiffe/go-spiffe/v2/bundle/x509bundle" "github.com/spiffe/go-spiffe/v2/spiffeid" "github.com/spi...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/handler.go
pkg/tcp/handler.go
package tcp import ( "net" ) // Handler is the TCP Handlers interface. type Handler interface { ServeTCP(conn WriteCloser) } // The HandlerFunc type is an adapter to allow the use of // ordinary functions as handlers. type HandlerFunc func(conn WriteCloser) // ServeTCP serves tcp. func (f HandlerFunc) ServeTCP(co...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/wrr_load_balancer_test.go
pkg/tcp/wrr_load_balancer_test.go
package tcp import ( "net" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestWRRLoadBalancer_LoadBalancing(t *testing.T) { testCases := []struct { desc string serversWeight map[string]int totalCall int expectedWrite map[string]int expe...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/proxy_windows.go
pkg/tcp/proxy_windows.go
//go:build windows // +build windows package tcp import ( "errors" "net" "syscall" ) // isReadConnResetError reports whether err is a connection reset error during a read operation. func isReadConnResetError(err error) bool { var oerr *net.OpError return errors.As(err, &oerr) && oerr.Op == "read" && errors.Is(e...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/tls.go
pkg/tcp/tls.go
package tcp import ( "crypto/tls" ) // TLSHandler handles TLS connections. type TLSHandler struct { Next Handler Config *tls.Config } // ServeTCP terminates the TLS connection. func (t *TLSHandler) ServeTCP(conn WriteCloser) { t.Next.ServeTCP(tls.Server(conn, t.Config)) }
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/tcp/proxy_unix.go
pkg/tcp/proxy_unix.go
//go:build !windows // +build !windows package tcp import ( "errors" "net" "syscall" ) // isReadConnResetError reports whether err is a connection reset error during a read operation. func isReadConnResetError(err error) bool { var oerr *net.OpError return errors.As(err, &oerr) && oerr.Op == "read" && errors.Is...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/ping/ping.go
pkg/ping/ping.go
package ping import ( "context" "fmt" "net/http" ) // Handler expose ping routes. type Handler struct { EntryPoint string `description:"EntryPoint" json:"entryPoint,omitempty" toml:"entryPoint,omitempty" yaml:"entryPoint,omitempty" export:"true"` ManualRouting bool `description:"Manual routi...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/smart_builder.go
pkg/proxy/smart_builder.go
package proxy import ( "crypto/tls" "fmt" "net/http" "net/url" "time" "github.com/traefik/traefik/v3/pkg/config/dynamic" "github.com/traefik/traefik/v3/pkg/config/static" "github.com/traefik/traefik/v3/pkg/proxy/fast" "github.com/traefik/traefik/v3/pkg/proxy/httputil" "github.com/traefik/traefik/v3/pkg/serv...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/smart_builder_test.go
pkg/proxy/smart_builder_test.go
package proxy import ( "encoding/pem" "net/http" "net/http/httptest" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/config/dynamic" "github.com/traefik/traefik/v3/pkg/config/static" "github.com/traefik/traefik/v3/pkg/proxy/httpu...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/connpool.go
pkg/proxy/fast/connpool.go
package fast import ( "bufio" "errors" "fmt" "io" "net" "net/http" "net/http/httputil" "strings" "sync" "sync/atomic" "time" "github.com/rs/zerolog/log" "github.com/valyala/fasthttp" ) // rwWithUpgrade contains a ResponseWriter and an upgradeHandler, // used to upgrade the connection (e.g. Websockets). ...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/proxy.go
pkg/proxy/fast/proxy.go
package fast import ( "bufio" "bytes" "encoding/base64" "fmt" "io" "net" "net/http" "net/http/httptrace" "net/url" "strings" "sync" "github.com/rs/zerolog/log" proxyhttputil "github.com/traefik/traefik/v3/pkg/proxy/httputil" "github.com/valyala/fasthttp" "golang.org/x/net/http/httpguts" ) const ( buf...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/dialer.go
pkg/proxy/fast/dialer.go
package fast import ( "bufio" "context" "crypto/tls" "encoding/base64" "errors" "net" "net/http" "net/url" "strings" "time" "golang.org/x/net/proxy" ) const ( schemeHTTP = "http" schemeHTTPS = "https" schemeSocks5 = "socks5" ) type dialer interface { Dial(network, addr string) (c net.Conn, err err...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/proxy_websocket_test.go
pkg/proxy/fast/proxy_websocket_test.go
package fast import ( "bufio" "crypto/sha1" "crypto/tls" "encoding/base64" "errors" "fmt" "net" "net/http" "net/http/httptest" "net/url" "testing" "time" gorillawebsocket "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traef...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/proxy_test.go
pkg/proxy/fast/proxy_test.go
package fast import ( "crypto/tls" "crypto/x509" "encoding/base64" "fmt" "io" "net" "net/http" "net/http/httptest" "net/http/httputil" "net/url" "testing" "time" "github.com/armon/go-socks5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/c...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/connpool_test.go
pkg/proxy/fast/connpool_test.go
package fast import ( "net" "runtime" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestConnPool_ConnReuse(t *testing.T) { testCases := []struct { desc string poolFn func(pool *connPool) expected int }{ { desc: "One connection", poolFn:...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/builder.go
pkg/proxy/fast/builder.go
package fast import ( "crypto/tls" "fmt" "net" "net/http" "net/url" "reflect" "time" "github.com/traefik/traefik/v3/pkg/config/dynamic" "github.com/traefik/traefik/v3/pkg/config/static" ) // TransportManager manages transport used for backend communications. type TransportManager interface { Get(name strin...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/fast/upgrade.go
pkg/proxy/fast/upgrade.go
package fast import ( "context" "fmt" "io" "net" "net/http" "strings" "github.com/traefik/traefik/v3/pkg/proxy/httputil" "github.com/valyala/fasthttp" "golang.org/x/net/http/httpguts" ) // switchProtocolCopier exists so goroutines proxying data back and // forth have nice names in stacks. type switchProtoco...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/observability_test.go
pkg/proxy/httputil/observability_test.go
package httputil import ( "net/http" "net/http/httptest" "testing" "time" "github.com/stretchr/testify/require" ptypes "github.com/traefik/paerser/types" "github.com/traefik/traefik/v3/pkg/middlewares/observability" "github.com/traefik/traefik/v3/pkg/observability/metrics" otypes "github.com/traefik/traefik/...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/proxy.go
pkg/proxy/httputil/proxy.go
package httputil import ( "context" "crypto/tls" "errors" "io" stdlog "log" "net" "net/http" "net/http/httputil" "net/url" "strings" "time" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/traefik/traefik/v3/pkg/observability/logs" "golang.org/x/net/http/httpguts" ) type key string con...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/proxy_websocket_test.go
pkg/proxy/httputil/proxy_websocket_test.go
package httputil import ( "bufio" "bytes" "crypto/tls" "errors" "fmt" "net" "net/http" "net/http/httptest" "testing" "time" gorillawebsocket "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/testhelpers" "golang....
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/bufferpool.go
pkg/proxy/httputil/bufferpool.go
package httputil import "sync" const bufferSize = 32 * 1024 type bufferPool struct { pool sync.Pool } func newBufferPool() *bufferPool { b := &bufferPool{ pool: sync.Pool{}, } b.pool.New = func() interface{} { return make([]byte, bufferSize) } return b } func (b *bufferPool) Get() []byte { return b.po...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/proxy_test.go
pkg/proxy/httputil/proxy_test.go
package httputil import ( "crypto/tls" "errors" "net/http" "net/http/httptest" "net/http/httputil" "net/url" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/testhelpers" ) func Test_rewriteRequestBuilder(t *testing.T) { tests := []str...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/builder.go
pkg/proxy/httputil/builder.go
package httputil import ( "crypto/tls" "fmt" "net/http" "net/url" "time" "github.com/traefik/traefik/v3/pkg/config/dynamic" "github.com/traefik/traefik/v3/pkg/observability/metrics" ) // TransportManager manages transport used for backend communications. type TransportManager interface { Get(name string) (*d...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/observability.go
pkg/proxy/httputil/observability.go
package httputil import ( "context" "fmt" "net" "net/http" "strconv" "strings" "time" "github.com/traefik/traefik/v3/pkg/middlewares/observability" "github.com/traefik/traefik/v3/pkg/observability/metrics" "github.com/traefik/traefik/v3/pkg/observability/tracing" "go.opentelemetry.io/otel/attribute" semco...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/proxy/httputil/builder_test.go
pkg/proxy/httputil/builder_test.go
package httputil import ( "crypto/tls" "errors" "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/traefik/traefik/v3/pkg/config/dynamic" "github.com/traefik/traefik/v3/pkg/testhelpers" ) func TestEscapedPath(t *testing.T) { var g...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/ip/checker.go
pkg/ip/checker.go
package ip import ( "errors" "fmt" "net" "net/netip" "strings" ) // Checker allows to check that addresses are in a trusted IPs. type Checker struct { authorizedIPs []*net.IP authorizedIPsNet []*net.IPNet } // NewChecker builds a new Checker given a list of CIDR-Strings to trusted IPs. func NewChecker(trus...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/ip/checker_test.go
pkg/ip/checker_test.go
package ip import ( "net" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestIsAuthorized(t *testing.T) { testCases := []struct { desc string allowList []string remoteAddr string authorized bool }{ { desc: "remoteAddr not in range", allo...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/ip/strategy.go
pkg/ip/strategy.go
package ip import ( "net" "net/http" "net/netip" "strings" ) const ( xForwardedFor = "X-Forwarded-For" ) // Strategy a strategy for IP selection. type Strategy interface { GetIP(req *http.Request) string } // RemoteAddrStrategy a strategy that always return the remote address. type RemoteAddrStrategy struct {...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/ip/strategy_test.go
pkg/ip/strategy_test.go
package ip import ( "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) const ( ipv6Basic = "::abcd:ffff:c0a8:1" ipv6BracketsPort = "[::abcd:ffff:c0a8:1]:80" ipv6BracketsZonePort = "[::abcd:ffff:c0a8:1%1]:80" ) func TestRemoteA...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false
traefik/traefik
https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/testhelpers/metrics.go
pkg/testhelpers/metrics.go
package testhelpers import "github.com/go-kit/kit/metrics" // CollectingCounter is a metrics.Counter implementation that enables access to the CounterValue and LastLabelValues. type CollectingCounter struct { CounterValue float64 LastLabelValues []string } // With is there to satisfy the metrics.Counter interfa...
go
MIT
f7280439e6378221a541910f43a01323d52db048
2026-01-07T08:35:43.502324Z
false