func ParseChannelUrl(cUrl string) *LinkUrl {
	if cUrl == "" {
		return DefaultLinkUrl()
	}
	return NewLinkUrl(cUrl)
}
///////////////////////////////////////////////////////////////
Helper functions for TGChannelUrl
///////////////////////////////////////////////////////////////
package impl
import (
	"bytes"
	"crypto"
	"encoding/binary"
	"crypto/rand"
	"crypto/tls"
	"crypto/x509"
	"crypto/x509/pkix"
	"encoding/gob"
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"syscall"
	"tgdb"
	"time"
)
const (
	gDefaultHost string = "localhost"
	gDefaultPort int    = 8222
)
type LinkUrl struct {
	ftUrls   []tgdb.TGChannelUrl
	urlHost  string
	isIPv6   bool
	urlPort  int
	protocol tgdb.TGProtocol
	urlStr   string
	urlProps *SortedProperties  
	urlUser  string
}
func DefaultLinkUrl() *LinkUrl {
	gob.Register(LinkUrl{})
	tgEnv := NewTGEnvironment()
	newChannelUrl := LinkUrl{
		ftUrls:   make([]tgdb.TGChannelUrl, 0),
		urlHost:  tgEnv.GetChannelDefaultHost(),
		isIPv6:   false,
		urlPort:  tgEnv.GetChannelDefaultPort(),
		protocol: tgdb.ProtocolTCP,
		urlProps: &SortedProperties{},
		urlUser:  tgEnv.GetChannelDefaultUser(),
	}
	defaultFtUrls := tgEnv.GetChannelFTHosts()
	if len(defaultFtUrls) > 0 {
		ftUrls := strings.Split(defaultFtUrls, ",")
		for _, ftUrl := range ftUrls {
			if ftUrl != "" {
				newLinkUrl := NewLinkUrl(ftUrl)
				newChannelUrl.ftUrls = append(newChannelUrl.ftUrls, newLinkUrl)
			}
		}
	}
	return &newChannelUrl
}
func NewLinkUrl(sUrl string) *LinkUrl {
	newChannelUrl := DefaultLinkUrl()
	sUrl = strings.TrimSpace(sUrl)
	proto, host, port, ip6Flag, user, ftUrls, props, err := parseUrlComponents(sUrl)
	if err != nil {
		return nil
	}
	newChannelUrl.urlStr = sUrl
	newChannelUrl.isIPv6 = ip6Flag
	newChannelUrl.urlHost = host
	newChannelUrl.urlPort = port
	newChannelUrl.protocol = proto
	newChannelUrl.ftUrls = ftUrls
	if props != nil {
		newChannelUrl.urlProps = props.(*SortedProperties)
	}
	newChannelUrl.urlUser = user
	newChannelUrl.urlProps.AddProperty(GetConfigFromKey(ChannelUserID).GetName(), user)
	return newChannelUrl
}
func NewLinkUrlWithComponents(proto tgdb.TGProtocol, host string, port int) *LinkUrl {
	newChannelUrl := DefaultLinkUrl()
	newChannelUrl.urlHost = host
	newChannelUrl.urlPort = port
	newChannelUrl.protocol = proto
	return newChannelUrl
}