sip

package module
v0.0.0-...-dd2792d Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CR = '\r'
	LF = '\n'
)
View Source
const (
	MethodRegister = "REGISTER"
	MethodInvite   = "INVITE"
	MethodCancel   = "CANCEL"
	MethodAck      = "ACK"
	MethodBye      = "BYE"
	MethodOptions  = "OPTIONS"
	MethodOther    = "OTHER"
	MethodMessage  = "MESSAGE"
)
View Source
const (
	OK = 200
)

Variables

View Source
var ErrClientClosed = fmt.Errorf("client be closed")
View Source
var ErrClientNotConnected = fmt.Errorf("client is not connected")

Functions

func GenerateAuthorizationResponse

func GenerateAuthorizationResponse(method, username, realm, password, nonce, uri string) string

Types

type Client

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

func NewClient

func NewClient(sipaccount string, password string) (*Client, error)

func (*Client) Accept

func (client *Client) Accept() (pkt interface{}, err error)

func (*Client) Close

func (client *Client) Close() (err error)

func (*Client) Dial

func (client *Client) Dial() (err error)

func (*Client) Register

func (client *Client) Register() (err error)

func (*Client) Request

func (client *Client) Request(method string, seq int64, sipaccount string, body []byte, headers map[string]header.HeaderValue) (res <-chan *Response, err error)

func (*Client) Write

func (client *Client) Write(pkt interface{}) error

type Cred

type Cred struct {
	Username string
	Realm    string // Realm. Use "*" to make a credential that can be used to authenticate against any challenges.
	Scheme   string // Scheme (e.g. "digest").
	DataType int    //Type of data (0 for plaintext passwd).
	Data     string // The data, which can be a plaintext password or a hashed digest.
}

type Handler

type Handler interface {
	OnRequest(conn xnet.Conn, req *Request)
	OnResponse(conn xnet.Conn, res *Response)
}

A Handler responds to an HTTP request.

type Message

type Message struct {
	Headers map[string]header.HeaderValue
	Body    []byte
}

Message sip message

func NewMessage

func NewMessage() *Message

func (*Message) Accept

func (msg *Message) Accept() *header.Accept

func (*Message) Allow

func (msg *Message) Allow() *header.Allow

func (*Message) Authorization

func (msg *Message) Authorization() *header.Authorization

func (*Message) CSeq

func (msg *Message) CSeq() *header.CSeq

func (*Message) CallID

func (msg *Message) CallID() *header.CallID

func (*Message) Contact

func (msg *Message) Contact() *header.Contact

func (*Message) ContentLength

func (msg *Message) ContentLength() *header.ContentLength

func (*Message) ContentType

func (msg *Message) ContentType() *header.String

func (*Message) Date

func (msg *Message) Date() *header.Date

func (*Message) Expires

func (msg *Message) Expires() *header.Expires

func (*Message) From

func (msg *Message) From() *header.From

func (*Message) Marshal

func (msg *Message) Marshal() []byte

func (*Message) MaxForwards

func (msg *Message) MaxForwards() *header.MaxForwards

func (*Message) SetAccept

func (msg *Message) SetAccept(val *header.Accept)

func (*Message) SetAllow

func (msg *Message) SetAllow(val *header.Allow)

func (*Message) SetAuthorization

func (msg *Message) SetAuthorization(val *header.Authorization)

func (*Message) SetCSeq

func (msg *Message) SetCSeq(val *header.CSeq)

func (*Message) SetCallID

func (msg *Message) SetCallID(val *header.CallID)

func (*Message) SetContact

func (msg *Message) SetContact(val *header.Contact)

func (*Message) SetContentLength

func (msg *Message) SetContentLength(val *header.ContentLength)

func (*Message) SetContentType

func (msg *Message) SetContentType(val *header.String)

func (*Message) SetDate

func (msg *Message) SetDate(val *header.Date)

func (*Message) SetExpires

func (msg *Message) SetExpires(val *header.Expires)

func (*Message) SetFrom

func (msg *Message) SetFrom(val *header.From)

func (*Message) SetMaxForwards

func (msg *Message) SetMaxForwards(val *header.MaxForwards)

func (*Message) SetTo

func (msg *Message) SetTo(val *header.To)

func (*Message) SetVia

func (msg *Message) SetVia(val *header.Via)

func (*Message) SetWWWAuthenticate

func (msg *Message) SetWWWAuthenticate(val *header.WWWAuthenticate)

func (*Message) To

func (msg *Message) To() *header.To

func (*Message) Unmarshal

func (msg *Message) Unmarshal(b []byte) error

func (*Message) Via

func (msg *Message) Via() *header.Via

func (*Message) WWWAuthenticate

func (msg *Message) WWWAuthenticate() *header.WWWAuthenticate

type Request

type Request struct {
	*Message
	Method   string
	Protocal *header.Protocal
	URI      *header.URI

	LocalAddr  net.Addr
	RemoteAddr net.Addr
	// contains filtered or unexported fields
}

A Request represents an SIP request received by a server or to be sent by a client.

func NewRequest

func NewRequest() *Request

func (*Request) Marshal

func (req *Request) Marshal() []byte

func (*Request) Response

func (req *Request) Response() *Response

func (*Request) Unmarshal

func (req *Request) Unmarshal(b []byte) error

type Response

type Response struct {
	*Message
	Protocal   *header.Protocal
	StatusCode int
	Reason     string
	// contains filtered or unexported fields
}

Response sip response

func AuthSrvChallenge

func AuthSrvChallenge(req *Request, realm string) (res *Response)

func AuthSrvVerify

func AuthSrvVerify(req *Request, cred *Cred) (res *Response, ok bool)

func CreateResponseFromRequest

func CreateResponseFromRequest(req *Request, status int) (res *Response)

func NewResponse

func NewResponse() *Response

func NewResponseWithStatus

func NewResponseWithStatus(status int) *Response

func (*Response) Marshal

func (res *Response) Marshal() []byte

func (*Response) Request

func (res *Response) Request() *Request

func (*Response) Unmarshal

func (res *Response) Unmarshal(b []byte) error

type Server

type Server struct {
	Addr    string
	Network string

	Handler Handler // handler to invoke
	// contains filtered or unexported fields
}

Server sip server

func (*Server) Close

func (srv *Server) Close() (err error)

Close server

func (*Server) Serve

func (srv *Server) Serve() (err error)

Serve listens on the network address srv.Addr and then calls Serve to handle requests on incoming connections

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) (err error)

Shutdown gracefully shuts down the server without interrupting any active connections

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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