new: keeping track of interface index

This commit is contained in:
evilsocket 2018-02-08 01:03:31 +01:00
commit 529d834815
3 changed files with 3 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import (
type OnHostResolvedCallback func(e *Endpoint)
type Endpoint struct {
Index int `json:"-"`
IP net.IP `json:"-"`
Net *net.IPNet `json:"-"`
IPv6 net.IP `json:"-"`

View file

@ -94,6 +94,7 @@ func FindInterface(name string) (*Endpoint, error) {
if len(e.HW) == 0 {
return nil, fmt.Errorf("Could not detect interface hardware address.")
}
e.Index = iface.Index
return e, nil
}
}

View file

@ -201,6 +201,7 @@ func (s *Session) Start() error {
s.Env.Set(PromptVariable, DefaultPrompt)
s.Env.Set("iface.index", fmt.Sprintf("%d", s.Interface.Index))
s.Env.Set("iface.name", s.Interface.Name())
s.Env.Set("iface.ipv4", s.Interface.IpAddress)
s.Env.Set("iface.ipv6", s.Interface.Ip6Address)