mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-08-29 04:31:50 +00:00
Transport WIP
This commit is contained in:
@@ -3,6 +3,7 @@ package acl
|
||||
import (
|
||||
"bufio"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -14,6 +15,7 @@ type Engine struct {
|
||||
DefaultAction Action
|
||||
Entries []Entry
|
||||
Cache *lru.ARCCache
|
||||
Transport core.Transport
|
||||
}
|
||||
|
||||
type cacheEntry struct {
|
||||
@@ -21,7 +23,7 @@ type cacheEntry struct {
|
||||
Arg string
|
||||
}
|
||||
|
||||
func LoadFromFile(filename string) (*Engine, error) {
|
||||
func LoadFromFile(filename string, transport core.Transport) (*Engine, error) {
|
||||
f, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -49,6 +51,7 @@ func LoadFromFile(filename string) (*Engine, error) {
|
||||
DefaultAction: ActionProxy,
|
||||
Entries: entries,
|
||||
Cache: cache,
|
||||
Transport: transport,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -56,7 +59,7 @@ func (e *Engine) ResolveAndMatch(host string) (Action, string, *net.IPAddr, erro
|
||||
ip, zone := parseIPZone(host)
|
||||
if ip == nil {
|
||||
// Domain
|
||||
ipAddr, err := net.ResolveIPAddr("ip", host)
|
||||
ipAddr, err := e.Transport.OutResolveIPAddr(host)
|
||||
if v, ok := e.Cache.Get(host); ok {
|
||||
// Cache hit
|
||||
ce := v.(cacheEntry)
|
||||
|
Reference in New Issue
Block a user