Example #1
0
extern void server_set_name(void)
{
    char temp[250];
    char const * sn;
#ifdef HAVE_GETHOSTBYNAME
    struct hostent *   hp;
#endif

    if (server_name) {
	free((void *)server_name); /* avoid warning */
	server_name = NULL;
    }

    sn = prefs_get_servername();
    if ((!sn)||(sn[0]=='\0')) {
    	if (gethostname(temp,sizeof(temp))<0) {
	    eventlog(eventlog_level_error,"server_set_name","could not get hostname: %s",strerror(errno));
	    return;
    	}
#ifdef HAVE_GETHOSTBYNAME
    	hp = gethostbyname(temp);
    	if (!hp || !hp->h_name) {
#endif
    	    server_name = strdup(temp);
#ifdef HAVE_GETHOSTBYNAME
    	} else {
	    int i=0;

	    if (strchr(hp->h_name,'.'))
	    	/* Default name is already a FQDN */
	    	server_name = strdup(hp->h_name);
	    /* ... if not we have to examine the aliases */
	    while (!server_name && hp->h_aliases && hp->h_aliases[i]) {
		if (strchr(hp->h_aliases[i],'.'))
		    server_name = strdup(hp->h_aliases[i]);
	    	i++;
	    }
	    if (!server_name)
		/* Fall back to default name which might not be a FQDN */
    	    	server_name = strdup(hp->h_name);
    	}
#endif
    } else {
	server_name = strdup(sn);
    }
    eventlog(eventlog_level_info,"server_set_name","set servername to \"%s\"",server_name);
}
Example #2
0
		static int _handle_whereto_command(t_connection * conn, int numparams, char ** params, char * text)
		{
			char temp[MAX_IRC_MESSAGE_LEN];

			/* Casted to avoid warnings */
			const char * wolip;
			const char * wolname = prefs_get_servername();
			const char * woltimezone = prefs_get_wol_timezone();
			const char * wollong = prefs_get_wol_longitude();
			const char * wollat = prefs_get_wol_latitude();

			{    /* trans support */
				unsigned short port = conn_get_real_local_port(conn);
				unsigned int addr = conn_get_real_local_addr(conn);

				trans_net(conn_get_addr(conn), &addr, &port);

				wolip = addr_num_to_ip_str(addr);
			}

			//irc_send(conn,RPL_UPDATE_EXIST,":You must update before connecting!");

			// Check if it's an allowed client type
			if (!tag_check_in_list(conn_get_clienttag(conn), prefs_get_allowed_clients())) {
				//  This is for anyone game but not for Emperor
				if (conn_get_clienttag(conn) != CLIENTTAG_EMPERORBD_UINT) {
					//        a.xwis.net 4009 RA2
					//        c.xwis.net 4000 TSUN
					//        c.xwis.net 4010 RNGD
					//        a.xwis.net 4010 YURI
					//            snprintf(temp, sizeof(temp), ":a.xwis.net 4009 '0:%s' %s %s %s", wolname, woltimezone, wollong, wollat);
					//            snprintf(temp, sizeof(temp), ":c.xwis.net 4000 '0:%s' %s %s %s", wolname, woltimezone, wollong, wollat);
					//            snprintf(temp, sizeof(temp), ":c.xwis.net 4010 '0:%s' %s %s %s", wolname, woltimezone, wollong, wollat);
					//            snprintf(temp, sizeof(temp), ":a.xwis.net 4010 '0:%s' %s %s %s", wolname, woltimezone, wollong, wollat);
					std::snprintf(temp, sizeof(temp), ":%s %d '0:%s' %s %s %s", wolip, BNETD_WOLV2_PORT, wolname, woltimezone, wollong, wollat);
					irc_send(conn, RPL_WOLSERV, temp);
				}

				//  Only for Emperor: Battle for Dune
				if (conn_get_clienttag(conn) == CLIENTTAG_EMPERORBD_UINT) {
					std::snprintf(temp, sizeof(temp), ":%s %d '0:Emperor %s' %s %s %s", wolip, BNETD_WOLV2_PORT, wolname, woltimezone, wollong, wollat);
					irc_send(conn, RPL_WOLSERV, temp);
				}

				//  Only for CnC Renegade
				if ((conn_get_clienttag(conn) == CLIENTTAG_RENEGADE_UINT) || (conn_get_clienttag(conn) == CLIENTTAG_RENGDFDS_UINT)) {
					snprintf(temp, sizeof(temp), ":%s 0 'Ping server' %s %s %s", wolip, woltimezone, wollong, wollat);
					irc_send(conn, RPL_PINGSERVER, temp);
					//I dont know for what is this server...? (used in renegade and yuri)
					//snprintf(temp, sizeof(temp), ":%s 4321 'Port Mangler' %s %s %s", wolip, woltimezone, wollong, wollat);
					//irc_send(conn,RPL_MANGLERSERV,temp);
					// on official server list is for Renegade also this server:
					//:noxchat1.wol.abn-sjc.ea.com 613 UserName :ea4.str.ea.com 0 '0,1,2,3,4,5,6,7,8,9,10:EA Ticket Server' -8 36.1083 -115.0582
				}

				//  There are servers for anyone game
				// FIXME: Check if is WOLv1 supported
				std::snprintf(temp, sizeof(temp), ":%s %d 'Live chat server' %s %s %s", wolip, BNETD_WOLV1_PORT, woltimezone, wollong, wollat);
				irc_send(conn, RPL_WOLSERV, temp);
			}

			// If game is not allowed than we still send this servers 
			std::snprintf(temp, sizeof(temp), ":%s %d 'Gameres server' %s %s %s", wolip, BNETD_WGAMERES_PORT, woltimezone, wollong, wollat);
			irc_send(conn, RPL_GAMERESSERV, temp);
			std::snprintf(temp, sizeof(temp), ":%s %d 'Ladder server' %s %s %s", wolip, BNETD_WOLV2_PORT, woltimezone, wollong, wollat);
			irc_send(conn, RPL_LADDERSERV, temp);
			// There is Word Domination Tour server for Firestorm (maybe for future coding)
			//snprintf(temp, sizeof(temp), ":%s %d 'WDT server' %s %s %s", wolip, BNETD_WOLV2_PORT, woltimezone, wollong, wollat); //I dont know for what is this server...?
			//irc_send(conn,RPL_WDTSERV,temp);

			return 0;
		}