set proper clientversion, better version/tag extraction

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
. 2016-05-09 18:30:24 +12:00
parent 9c2cad7986
commit 169debea93
2 changed files with 23 additions and 12 deletions

View File

@ -57,7 +57,8 @@ type Server struct {
func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server {
self := libnmdc.NewUserInfo("")
self.ClientTag = APP_DESCRIPTION
self.ClientTag = APP_NAME
self.ClientVersion = APP_VERSION
return &Server{
name: name,
@ -280,10 +281,10 @@ func (s *Server) handleCommand(command string, args []string) {
// do nothing
case "INFO":
s.reply(rplInfo, APP_DESCRIPTION)
s.reply(rplInfo, APP_NAME+" v"+APP_VERSION)
case "VERSION":
s.reply(rplVersion, VERSION)
s.reply(rplVersion, APP_VERSION)
case "MOTD":
s.sendMOTD(s.motd)
@ -430,18 +431,28 @@ func (s *Server) SetClientSoftwareVersion(ver string) {
// "liteIRC for Android 1.1.8"
// ":Relay:1.0:Android"
// A bit long and unwieldy. Heuristic: stop after the first word containing digits
// A bit long and unwieldy.
// Heuristic: keep the first word, and the the first word containing digits
parts := regexp.MustCompilePOSIX("^([^0-9]*[0-9]+[^ ]*) ").FindStringSubmatch(ver)
tag := APP_NAME
version := APP_VERSION
if len(parts) > 0 {
ver = strings.TrimRight(parts[0], " ")
words := strings.Split(ver, " ")
for _, word := range words[1:] {
if strings.ContainsAny(word, "0123456789") {
tag = words[0]
version = strings.Replace(word, "(", "", -1) // AndroIRC
break
}
}
s.verbosef("Replacing client tag with '%s'...", ver)
s.verbosef("Replacing client tag with '%s' version '%s'", tag, version)
s.upstreamLauncher.Self.ClientTag = ver
s.upstream.Hco.Self.ClientTag = ver
s.upstreamLauncher.Self.ClientTag = tag
s.upstreamLauncher.Self.ClientVersion = version
s.upstream.Hco.Self.ClientTag = tag
s.upstream.Hco.Self.ClientVersion = version
s.upstream.SayInfo()
}

View File

@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const (
VERSION = "1.0.0"
APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION
APP_VERSION = "1.0.0"
APP_NAME = "nmdc-ircfrontend"
BLESSED_CHANNEL = "#chat" // must be lowercase
BLESSED_CHANNEL_MODE = "n" // means that you have to be in the channel to chat, but that's it