Thanks for the replies. I also found nethost.c, but it is for Anope's NickServ
Code: Select all
#include <stdio.h>
#include "module.h"
#define AUTHOR "Certus"
#define VERSION "2.1"
/**
* network-vhost on nickserv register
* Date: 11/07/2003
* Author: Certus <[email protected]>
**/
/* PLEASE EDIT THIS LINE LIKE YOU WANT IT,
* BUT REMEMBER: IF EACH USER HAS THE SAME HOST, HOST-BANS WON'T WORK,
* SO U BETTER LEAVE IT UNDEFINED; WITH AN UNDEFINED NETHOST, THE NET-
* WORK VHOST WILL BE <nickname>.<NetworkDomain>, SO MAKE SURE THAT
* NetworkDomain IS DEFINED IN YOUR SERVICES CONFIG FILE
*/
//#define NETHOST "test.anope.org"
/* DON'T CHANGE ANY OF THE LINES BELOW, UNLESS YOU REALLY KNOW WHAT YOU DO */
int set_netvhost(User *u);
int set_confirm_netvhost(User *u);
char dilim = ' ';
extern void addHostCore(char *nick, char *vIdent, char *vhost, char *creator, int32 tmp_time);
void AnopeInit(void) {
Command *c;
c=createCommand("register",set_netvhost,NULL,-1,-1,-1,-1,-1);
alog("Loading module hs_nethost.so [Status: %d]",moduleAddCommand(NICKSERV,c,MOD_TAIL));
c=createCommand("group",set_netvhost,NULL,-1,-1,-1,-1,-1);
moduleAddCommand(NICKSERV,c,MOD_TAIL);
c=createCommand("confirm",set_confirm_netvhost,NULL,-1,-1,-1,-1,-1);
moduleAddCommand(NICKSERV,c,MOD_TAIL);
#ifndef NETHOST
if (NetworkDomains[0])
alog("Network vHost: nickname.%s", NetworkDomains[0]);
#else
alog("Network vHost: %s", NETHOST);
#endif
}
void AnopeFini(void) {
alog("Unloading module hs_nethost.so");
}
int set_netvhost(User *u) {
int32 tmp_time;
char *vIdent = NULL;
char *networkhost=NULL;
int len = 0;
tmp_time = time(NULL);
if (!nick_identified(u))
return MOD_CONT;
#ifndef NETHOST
if(NetworkDomains[0]) {
len = strlen(NetworkDomains[0]);
len += strlen(u->nick);
if((networkhost = malloc(sizeof(char)*len+3))!=NULL) {
strcpy(networkhost,u->nick);
strcat(networkhost,".");
strcat(networkhost,NetworkDomains[0]);
} else {
return MOD_CONT;
}
} else {
return MOD_CONT;
}
#else
networkhost = sstrdup(NETHOST);
#endif
if (!isValidHost(networkhost, 3)) {
notice(s_HostServ, u->nick, "Nick %s contains invalid vhosts characters. The vhost won't be set. [This is not a bug!]", u->nick);
free(networkhost);
return MOD_CONT;
}
addHostCore(u->nick, vIdent, networkhost, u->nick, tmp_time);
notice_lang(s_HostServ, u, HOST_SET, u->nick, networkhost);
do_on_id(u);
free(networkhost);
return MOD_CONT;
}
int set_confirm_netvhost(User *u) {
int32 tmp_time;
char *nick = NULL;
char *vIdent = NULL;
char *networkhost=NULL;
char *command = NULL;
int len = 0;
tmp_time = time(NULL);
command = moduleGetLastBuffer();
if (!NSEmailReg) {
notice(s_NickServ, u->nick, "NSEmailReg is not active");
return MOD_CONT;
}
if (!nick_identified(u)) {
return MOD_CONT;
}
if (is_services_admin(u)) {
nick = myStrGetToken(command, dilim, 0);
if (!nick)
return MOD_CONT;
if (!findnick(nick))
return MOD_CONT;
} else {
nick = u->nick;
}
#ifndef NETHOST
if(NetworkDomains[0]) {
len = strlen(NetworkDomains[0]);
len += strlen(nick);
if((networkhost = malloc(sizeof(char)*len+3))!=NULL) {
strcpy(networkhost,nick);
strcat(networkhost,".");
strcat(networkhost,NetworkDomains[0]);
} else {
return MOD_CONT;
}
} else {
return MOD_CONT;
}
#else
networkhost = sstrdup(NETHOST);
#endif
if (!isValidHost(networkhost, 3)) {
notice(s_HostServ, u->nick, "Nick %s contains invalid vhosts characters. The vhost won't be set. [This is not a bug!]", nick);
free(networkhost);
return MOD_CONT;
}
addHostCore(nick, vIdent, networkhost, nick, tmp_time);
notice_lang(s_HostServ, u, HOST_SET, nick, networkhost);
if (!is_services_admin(u))
do_on_id(u);
free(networkhost);
return MOD_CONT;
}
I think that will do the job. If it dosen't I will pay for it.