2021-09-19 20:28:38 +08:00
|
|
|
package conf
|
|
|
|
|
|
|
|
|
|
import (
|
2026-06-19 07:17:01 +08:00
|
|
|
"github.com/xtls/xray-core/common/errors"
|
2021-09-19 20:28:38 +08:00
|
|
|
"github.com/xtls/xray-core/proxy/loopback"
|
2023-08-10 04:43:34 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
2021-09-19 20:28:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type LoopbackConfig struct {
|
2026-06-19 07:17:01 +08:00
|
|
|
InboundTag string `json:"inboundTag"`
|
|
|
|
|
Sniffing *SniffingConfig `json:"sniffing"`
|
2021-09-19 20:28:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l LoopbackConfig) Build() (proto.Message, error) {
|
2026-06-19 07:17:01 +08:00
|
|
|
c := &loopback.Config{InboundTag: l.InboundTag}
|
|
|
|
|
if l.Sniffing != nil {
|
|
|
|
|
sc, err := l.Sniffing.Build()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, errors.New("failed to build sniffing config").Base(err)
|
|
|
|
|
}
|
|
|
|
|
c.Sniffing = sc
|
|
|
|
|
}
|
|
|
|
|
return c, nil
|
2021-09-19 20:28:38 +08:00
|
|
|
}
|