Example #1
0
func nameUpdates(net interfaces.Network, data editRequest, oldData messages.NetData) {
	if len(data.Name) > 0 && data.Name != oldData.Name {
		net.SetName(data.Name)
	}

	if len(data.Nick) > 0 && data.Nick != oldData.Nick {
		net.SetNick(data.Nick)
	}

	if len(data.Realname) > 0 && data.Realname != oldData.Realname {
		net.SetRealname(data.Realname)
	}

	if len(data.User) > 0 && data.User != oldData.User {
		net.SetUser(data.User)
	}
}
Example #2
0
func connectedUpdate(net interfaces.Network, data editRequest, oldData messages.NetData) {
	if len(data.Connected) == 0 {
		return
	}
	connected := strings.ToLower(data.Connected) == "true"
	if connected != oldData.Connected {
		if connected {
			net.Connect()
		} else {
			net.Disconnect()
		}
	} else if data.ForceDisconnect {
		net.ForceDisconnect()
	}
}
Example #3
0
func addrUpdates(net interfaces.Network, data editRequest, oldData messages.NetData) {
	if len(data.IP) > 0 && data.IP != oldData.IP {
		net.SetIP(data.IP)
	}

	if data.Port > 0 && data.Port != oldData.Port {
		net.SetPort(data.Port)
	}

	if len(data.SSL) > 0 {
		ssl := strings.ToLower(data.SSL) == "true"
		if ssl != oldData.SSL {
			net.SetSSL(ssl)
		}
	}
}