Feature: add DST-PORT and SRC-PORT

This commit is contained in:
Dreamacro
2019-05-09 21:00:29 +08:00
parent cff4841f3e
commit 225c530d13
17 changed files with 137 additions and 59 deletions

View File

@ -13,7 +13,7 @@ const (
TCP NetWork = iota
UDP
HTTP SourceType = iota
HTTP Type = iota
SOCKS
REDIR
)
@ -27,26 +27,27 @@ func (n *NetWork) String() string {
return "udp"
}
type SourceType int
type Type int
// Metadata is used to store connection address
type Metadata struct {
NetWork NetWork
Source SourceType
SourceIP *net.IP
Type Type
SrcIP *net.IP
DstIP *net.IP
SrcPort string
DstPort string
AddrType int
Host string
IP *net.IP
Port string
}
func (m *Metadata) String() string {
if m.Host == "" {
return m.IP.String()
return m.DstIP.String()
}
return m.Host
}
func (m *Metadata) Valid() bool {
return m.Host != "" || m.IP != nil
return m.Host != "" || m.DstIP != nil
}