func FillTargetHostAndPort(network string, target *Target) *Target {
	if strings.TrimSpace(target.Host) == "" {
		target.Host = DefaultHost
	}
	if target.Port == nil {
		p := sip.DefaultPort(network)
		target.Port = &p
	}
	return target
}
Fills endpoint target with default values.
package transport
import (
	"errors"
	"fmt"
	"io"
	"net"
	"regexp"
	"strconv"
	"strings"
	"github.com/ghettovoice/gosip/log"
	"github.com/ghettovoice/gosip/sip"
)
const (
	MTU = sip.MTU
	DefaultHost     = sip.DefaultHost
	DefaultProtocol = sip.DefaultProtocol
	DefaultUdpPort = sip.DefaultUdpPort
	DefaultTcpPort = sip.DefaultTcpPort
	DefaultTlsPort = sip.DefaultTlsPort
	DefaultWsPort  = sip.DefaultWsPort
	DefaultWssPort = sip.DefaultWssPort
)
type Target struct {
	Host string
	Port *sip.Port
}
func (trg *Target) Addr() string {
	var (
		host string
		port sip.Port
	)
	if strings.TrimSpace(trg.Host) != "" {
		host = trg.Host
	} else {
		host = DefaultHost
	}
	if trg.Port != nil {
		port = *trg.Port
	}
	return fmt.Sprintf("%v:%v", host, port)
}
func (trg *Target) String() string {
	if trg == nil {
		return "<nil>"
	}
	fields := log.Fields{
		"target_addr": trg.Addr(),
	}
	return fmt.Sprintf("transport.Target<%s>", fields)
}
func NewTarget(host string, port int) *Target {
	cport := sip.Port(port)
	return &Target{Host: host, Port: &cport}
}
func NewTargetFromAddr(addr string) (*Target, error) {
	host, port, err := net.SplitHostPort(addr)
	if err != nil {
		return nil, err
	}
	iport, err := strconv.Atoi(port)
	if err != nil {
		return nil, err
	}
	return NewTarget(host, iport), nil
}