ztesip

package
v0.0.0-...-421fa80 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const SipConfigName string = "ztesip.ini"

Variables

This section is empty.

Functions

func CreateTcpTls

func CreateTcpTls(host string, msg *SipMsg, isSSL bool)

func CreateWsWss

func CreateWsWss(host string, msg *SipMsg, isSSL bool)

func GetRemote

func GetRemote(ctype Transport, conn interface{}) net.Addr

func LocalIps

func LocalIps() []net.IP

func ParseSip

func ParseSip()

func StreamClient

func StreamClient(conn interface{}, firstmsg *SipMsg, isws bool, isSSL bool) error

func UdpMain

func UdpMain(ip string, port int)

func WSSServer

func WSSServer(cfg *SipConfig)

func WSServer

func WSServer(cfg *SipConfig)

Types

type ClientInfo

type ClientInfo struct {
	ID       UUID
	ConnType Transport //proto should be  UDP/TCP/TLS/WS/WSS
	PeerAddr string    //ip:port

	PacketSendCh chan *PacketSendMsg //接收数据通道
	ExitCh       chan interface{}    //接收退出消息通道
}

type ClientMgr

type ClientMgr struct {
	LocalIP   string //local ip
	UdpPort   int
	Clients   map[UUID]*ClientInfo //ID
	ViaTable  map[ViaKey]UUID
	NameTable map[string]UUID //when called,we can use user name to uuid[callee]
	Route     map[*regexp.Regexp]*Proxy
	UdpID     UUID
	Cfg       *MgrConfig //config
	SipCfg    *SipConfig
}

func NewClientMgr

func NewClientMgr(cfg *SipConfig) *ClientMgr

func (*ClientMgr) Add

func (mgr *ClientMgr) Add(msg *CreateMsg) error

func (*ClientMgr) Receive

func (mgr *ClientMgr) Receive(id UUID, msg *SipMsg) error

func (*ClientMgr) ReceiveRequest

func (mgr *ClientMgr) ReceiveRequest(id UUID, msg *SipMsg) error

func (*ClientMgr) ReceiveResponse

func (mgr *ClientMgr) ReceiveResponse(id UUID, msg *SipMsg) error

func (*ClientMgr) Remove

func (mgr *ClientMgr) Remove(id UUID) error

func (*ClientMgr) Run

func (mgr *ClientMgr) Run() error

func (*ClientMgr) Send

func (mgr *ClientMgr) Send(id UUID, proto Transport, remote string, msg *SipMsg) error

type ConnectionType

type ConnectionType int
const (
	Udp ConnectionType = 1 << iota
	Tcp
	Tls
	Ws
	Wss
	Sctp
)

type Contact

type Contact struct {
	Displayname string
	Username    string
	Domain      string
	Transport   Transport
	Expires     int
}

Contact: <sip:bpe4fc20@ha0af4gnfvl8.invalid;transport=ws>; expires=300;+sip.ice;reg-id=1;+sip.instance="<urn:uuid:93d317d6-3e58-42d1-a456-b56e1b30e33f>"

func NewContact

func NewContact(display, user, domain string, trans Transport, expires int) *Contact

func ParseContact

func ParseContact(s string) *Contact

func (*Contact) String

func (c *Contact) String() string

type CreateMsg

type CreateMsg struct {
	ID           UUID
	ConnType     Transport
	PeerAddr     string              //*net.TCPAddr
	PacketSendCh chan *PacketSendMsg //客户端构建,主控可以向该通道发送数据
	ExitCh       chan interface{}    //主控发送退出消息到客户端
}

type DestroyMsg

type DestroyMsg struct {
	ID UUID
}

type FromTo

type FromTo struct {
	IsFrom      bool
	Displayname string
	Username    string
	Domain      string
	Tag         string
}

From: <sip:alice@kf.zte.com.cn>;tag=bmsu89m4gi

func NewFromTo

func NewFromTo(isfrom bool, display, user, domain, tag string) *FromTo

func ParseFromTo

func ParseFromTo(isfrom bool, s string) *FromTo

func (*FromTo) String

func (f *FromTo) String() string

type Method

type Method string
const (
	INVITE    Method = "INVITE"
	ACK       Method = "ACK"
	CANCEL    Method = "CANCEL"
	BYE       Method = "BYE"
	REGISTER  Method = "REGISTER"
	OPTIONS   Method = "OPTIONS"
	SUBSCRIBE Method = "SUBSCRIBE"
	NOTIFY    Method = "NOTIFY"
	REFER     Method = "REFER"
)

type MgrConfig

type MgrConfig struct {
	CreateCh     chan *CreateMsg     //主控接收创建
	DestroyCh    chan *DestroyMsg    //主控接收销毁
	PacketRecvCh chan *PacketRecvMsg //主控接收数据通道
	StatusCh     chan *StatusMsg     //主控接收状态数据
}
var Config *MgrConfig

func NewMgrConfig

func NewMgrConfig() *MgrConfig

type PacketRecvMsg

type PacketRecvMsg struct {
	ID  UUID
	Msg *SipMsg
}

type PacketSendMsg

type PacketSendMsg struct {
	ID     UUID
	Proto  Transport
	Remote string //*net.UDPAddr //only for udp
	Msg    *SipMsg
}

type Proxy

type Proxy struct {
	Proto Transport //udp,tcp
	Ip    string
	Port  int
	User  string
	Pwd   string
}

type Route

type Route struct {
	Username string
	Domain   string
	Port     int
	IsStrict bool
}

func NewRoute

func NewRoute(Username, Domain string, Port int, IsStrict bool) *Route

func ParseRoute

func ParseRoute(s string) *Route

func (*Route) String

func (r *Route) String() string

func (*Route) ToSipUri

func (r *Route) ToSipUri() string

func (*Route) ValString

func (r *Route) ValString() string

type SipConfig

type SipConfig struct {
	Home         string
	MaxLinkNum   int
	HttpPort     int
	HttpsPort    int
	UdpPort      int
	TcpPort      int
	TlsPort      int
	WsPort       int
	WssPort      int
	XmlPort      int
	CertFileName string
	KeyFileName  string
	LogLevel     int
	LogPath      string

	Route      map[string]*SipRoute
	RouteOrder []string
	// contains filtered or unexported fields
}

func NewSipConfig

func NewSipConfig(fname string) *SipConfig

func (*SipConfig) AddRoute

func (sipcfg *SipConfig) AddRoute(r *SipRoute) error

func (*SipConfig) Load

func (sipcfg *SipConfig) Load(fname string) error

func (*SipConfig) ReadIni

func (sipcfg *SipConfig) ReadIni() error

func (*SipConfig) RemoveRoute

func (sipcfg *SipConfig) RemoveRoute(ip string) error

func (*SipConfig) Save

func (sipcfg *SipConfig) Save(fname string) error

func (*SipConfig) String

func (sipcfg *SipConfig) String() string

type SipMsg

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

func NewSipMsg

func NewSipMsg(data []byte) *SipMsg

func (*SipMsg) AddTopVia

func (msg *SipMsg) AddTopVia(v *Via) error

func (*SipMsg) Contact

func (msg *SipMsg) Contact() *Contact

func (*SipMsg) Decode

func (msg *SipMsg) Decode() error

func (*SipMsg) Encode

func (msg *SipMsg) Encode() ([]byte, error)

func (*SipMsg) FirstLine

func (msg *SipMsg) FirstLine() string

func (*SipMsg) FromTag

func (msg *SipMsg) FromTag() string

func (*SipMsg) IsRequest

func (msg *SipMsg) IsRequest() bool

func (*SipMsg) Method

func (msg *SipMsg) Method() Method

func (*SipMsg) OrigMsg

func (msg *SipMsg) OrigMsg() string

func (*SipMsg) RecvAddr

func (msg *SipMsg) RecvAddr() string

func (*SipMsg) RemoveTopRoute

func (msg *SipMsg) RemoveTopRoute() error

func (*SipMsg) RemoveTopVia

func (msg *SipMsg) RemoveTopVia() error

func (*SipMsg) SetContact

func (msg *SipMsg) SetContact(c *Contact) error

func (*SipMsg) SetFirstLine

func (msg *SipMsg) SetFirstLine(s string)

func (*SipMsg) SetRecvAddr

func (msg *SipMsg) SetRecvAddr(addr string) error

func (*SipMsg) SipUri

func (msg *SipMsg) SipUri() string

func (*SipMsg) String

func (msg *SipMsg) String() string

func (*SipMsg) ToUserName

func (msg *SipMsg) ToUserName() string

func (*SipMsg) TopRoute

func (msg *SipMsg) TopRoute() (*Route, error)

func (*SipMsg) TopVia

func (msg *SipMsg) TopVia() (*Via, error)

type SipMsgCodec

type SipMsgCodec interface {
	Encode() ([]byte, error)
	Decode(data []byte) error
}

type SipMsgCollecter

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

func (*SipMsgCollecter) Add

func (c *SipMsgCollecter) Add(data []byte) error

func (*SipMsgCollecter) Count

func (c *SipMsgCollecter) Count() int

func (*SipMsgCollecter) Remove

func (c *SipMsgCollecter) Remove() (*SipMsg, error)

type SipRoute

type SipRoute struct {
	IsPrefix bool
	Ip       string
	Port     int
	Proto    Transport
	Rule     string //userno@domain   ^userno or domain$
	Username string
	Password string
}

10.114.70.166 = *;ccm1000.zte.com.cn[;udp:5060[;user;pwd]]

func NewSipRoute

func NewSipRoute() *SipRoute

func (*SipRoute) NameVal

func (r *SipRoute) NameVal() (string, string)

func (*SipRoute) Parse

func (r *SipRoute) Parse(name, val string) error

func (*SipRoute) String

func (r *SipRoute) String() string

type StatusMsg

type StatusMsg struct {
	ID   UUID
	Code int
	Desc string
}

type Transport

type Transport string
const (
	UNKNOWN Transport = "UNKNOWN"
	UDP     Transport = "UDP"
	TCP     Transport = "TCP"
	TLS     Transport = "TLS"
	WS      Transport = "WS"
	WSS     Transport = "WSS"
	SCTP    Transport = "SCTP"
)

type UUID

type UUID string

type Via

type Via struct {
	Transport Transport
	SentBy    string
	Branch    string
}

Via: SIP/2.0/WSS ha0af4gnfvl8.invalid;branch=z9hG4bK1497770

func NewVia

func NewVia(trans Transport, host string, branch string) *Via

func ParseVia

func ParseVia(s string) *Via

func (*Via) Host

func (v *Via) Host() string

func (*Via) IsDataGram

func (v *Via) IsDataGram() bool

func (*Via) Key

func (v *Via) Key() string

func (*Via) String

func (v *Via) String() string

type ViaKey

type ViaKey string // Proto://SentBy

func (ViaKey) Host

func (v ViaKey) Host() string

Jump to

Keyboard shortcuts

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