netkit

package
v1.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 12 Imported by: 0

README

net

基础网络库方法

内置方法:

ping

p = net.ping(addr)

返回值字段:

  • ok
  • addr
  • cnt  返回的数据
  • time
  • seq
  • code
  • id
  • warp  报错
    local p = net.ping("127.0.0.1")
    print(p.ok)   -- true
    print(p.addr) -- 127.0.0.1
    print(p.cnt)  -- 32
    print(p.time) -- 56
    print(p.code) -- 200
    print(p.id)   -- 123091
    print(p.warp) -- error

ip

ip = net.ip("127.0.0.1") 获取IP地址对象

  • ipv4   判断是IPv4
  • ipv6   判断是IPv6

内置字段:

  • ip.ipv4
  • ip.ipv6
  • ip.invalid
    local v =  net.ipv4("127.0.0.1")
    print(v) --true

    local v = net.ipv6("aa::22")
    print(v) --true

    local v = net.ip("10.0.0.1")
    print(v.ipv4)  --true
    print(v.ipv6)  --false
    print(v.invalid)  --false

cat

c = net.cat(url , [body])
url: 请求标识 tcp://127.0.0.1:8080

返回值字段:

  • ok
  • banner
  • ont
  • cnt
  • err
    local c = net.cat("tcp://127.0.0.1:22")
    print(ok)     -- true
    print(banner) -- openssh-xxx-xx
    --todo

open

fd = net.open(url , banner)
url: 请求标识 tcp://127.0.0.1:8080 , banner:显示banner信息 , function: 处理请求connection

内置方法:

    local fd = net.open("tcp://127.0.0.1:9999" , "HTTP2.0")
    fd.hook(function(conn)
        --todo        
    end)
    fd.case("src == 127.0.0.1").pipe(print)

connection

链接套接字信息

  • push(v)
  • pushf(format , v...)
  • err  报错
  • raw  请求数据
  • src
  • dst
  • src_port
  • dst_port
  • source  127.0.0.1:9120
  • destination  127.0.0.1:80
    fd = net.open("tcp://127.0.0.1:9029" , "ssh2.0")
    fd.hook(function(conn) 
        print(conn.raw)
        print(conn.src)
        print(conn.dst)
        print(conn.err)
        conn.push(conn.raw)
    end)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Constructor added in v1.5.7

func Constructor(tab lua.UserKV)

func IPHelper added in v1.5.7

func IPHelper(L *lua.LState) addr

func Ipv4

func Ipv4(addr string) bool

func Ipv6

func Ipv6(addr string) bool

Types

type ICMP added in v1.5.7

type ICMP struct {
	Typ      uint8
	Code     uint8
	Checksum uint16
	ID       uint16
	Seq      uint16
}

ICMP 数据包结构体

type ReplyICMP added in v1.5.7

type ReplyICMP struct {
	Packet ICMP
	Addr   *net.IPAddr
	TTL    uint8
	Cnt    int
	Time   int64
	Err    error
}

func NewPing added in v1.5.7

func NewPing(dst string) ReplyICMP

func (ReplyICMP) AssertFloat64 added in v1.5.7

func (r ReplyICMP) AssertFloat64() (float64, bool)

func (ReplyICMP) AssertFunction added in v1.5.7

func (r ReplyICMP) AssertFunction() (*lua.LFunction, bool)

func (ReplyICMP) AssertString added in v1.5.7

func (r ReplyICMP) AssertString() (string, bool)

func (ReplyICMP) Hijack added in v1.5.7

func (r ReplyICMP) Hijack(fsm *lua.CallFrameFSM) bool

func (ReplyICMP) IP added in v1.5.7

func (r ReplyICMP) IP() string

func (ReplyICMP) Index added in v1.5.7

func (r ReplyICMP) Index(L *lua.LState, key string) lua.LValue

func (ReplyICMP) String added in v1.5.7

func (r ReplyICMP) String() string

func (ReplyICMP) Type added in v1.5.7

func (r ReplyICMP) Type() lua.LValueType

type URL added in v1.5.7

type URL struct {
	// contains filtered or unexported fields
}

tcp://127.0.0.1:53/?port=53&exclude=53

func NewURL added in v1.5.7

func NewURL(raw string) (URL, error)

func (*URL) Bool added in v1.5.7

func (u *URL) Bool(key string) bool

func (*URL) Host added in v1.5.7

func (u *URL) Host() string

func (*URL) Hostname added in v1.5.7

func (u *URL) Hostname() string

func (*URL) Int added in v1.5.7

func (u *URL) Int(key string) int

func (*URL) IsNil added in v1.5.7

func (u *URL) IsNil() bool

func (*URL) Port added in v1.5.7

func (u *URL) Port() int

func (*URL) Ports added in v1.5.7

func (u *URL) Ports() []int

func (*URL) R added in v1.5.7

func (u *URL) R(key string) map[int]struct{}

func (*URL) Scheme added in v1.5.7

func (u *URL) Scheme() string

func (*URL) String added in v1.5.7

func (u *URL) String() string

func (*URL) V4 added in v1.5.7

func (v *URL) V4() bool

func (*URL) V6 added in v1.5.7

func (v *URL) V6() bool

func (*URL) Value added in v1.5.7

func (u *URL) Value(key string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL