summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-05-08 00:29:19 +0100
committerFreeArtMan <dos21h@gmail.com>2017-05-08 00:29:19 +0100
commit0041b69fc5778d6be88d70e440cd8785b83d44dc (patch)
tree8a0e313146d8bedd025bb50222dbe31c6c53414b
parentd43cf6e4704da5414c80e32da06060ad06511f62 (diff)
downloadagni-0041b69fc5778d6be88d70e440cd8785b83d44dc.tar.gz
agni-0041b69fc5778d6be88d70e440cd8785b83d44dc.zip
Allow to connect only to predefine channels
-rw-r--r--agni.c37
-rw-r--r--config_servers.h36
2 files changed, 52 insertions, 21 deletions
diff --git a/agni.c b/agni.c
index 2bdba8b..968ea45 100644
--- a/agni.c
+++ b/agni.c
@@ -443,7 +443,7 @@ int th_start_client(void *data)
char *sep = strchr(uname,'!');
uname[sep-uname] = 0x0;
- PRINT()
+ PNL()
//if (token_cmp(itok,3,":join") == 1)
if (strncmp(":join",msg,5)==0)
{
@@ -451,15 +451,32 @@ int th_start_client(void *data)
//lets check if one more argument is there
{
- //PNL();
- char *sep_chan = strchr(msg,' ');
-
- //lets join channel
- memset(cmd_buf, 0, TH_CONN_BUF_SZ);
- int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ, ":%s JOIN %s\r\n", dest_name, sep_chan);
- PRINT("cmd_buf %s\n", cmd_buf);
- write(conn, cmd_buf, fret);
-
+ char *chan_name=NULL;
+ int iter=0;
+ char *sep_chan = strchr(msg,' ')+1;
+
+ //check if channel in allowed list, if yes then continue
+ iter=0;
+ while (cfg->channels[iter]!=NULL)
+ {
+ chan_name = cfg->channels[iter];
+ if ((strncmp(chan_name,sep_chan,strlen(chan_name))==0)
+ && (strlen(sep_chan)==strlen(chan_name)))
+ {
+ //lets join channel
+ memset(cmd_buf, 0, TH_CONN_BUF_SZ);
+ int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ, ":%s JOIN %s\r\n", dest_name, sep_chan);
+ PRINT("cmd_buf %s\n", cmd_buf);
+ write(conn, cmd_buf, fret);
+ break;
+ }
+ PNL();
+ iter++;
+ if (cfg->channels[iter]==NULL)
+ {
+ PRINT("Cant find this chan in da list\n");
+ }
+ }
}
} else
{
diff --git a/config_servers.h b/config_servers.h
index 8836db1..30a1105 100644
--- a/config_servers.h
+++ b/config_servers.h
@@ -10,29 +10,43 @@ typedef struct irc_server_conf
char *user;
char *password;
char *server;
- char **channels;
char *port;
int ssl;
+ char *channels[16];
} irc_server_conf;
static irc_server_conf server_list[] =
{
+ /*
{
- .user = "cbot_git2",
+ .user = "cbot_git2",#meeseekeria
.password = "asdsada",
.server = "irc.freenode.net",
- .channels = {"#mainlv",NULL},
+ .channels = {"#mainlv","#developerslv","#meeseekeria",NULL},
.port = "6667",
.ssl = 0,
- }/*,
+ },
+ */
+ /*
{
- .user = "agni",
- .password = NULL,
- .server = "irc.hacking.allowed.org",
- .channels = {"#default","#bot",NULL},
- .port = 6697,
- .ssl = 1,
- }*/
+ .user = "cbot_git",
+ .password = "asdaasda",
+ .server = "localhost",
+ .channels = {"#default","#bots",NULL},
+ .port = "9000",
+ //.port = "6667",
+ .ssl = 0
+ },
+ */
+
+ {
+ .user = "cbot_git",
+ .password = "asdaasda",
+ .server = "localhost",
+ .channels = {"#default","#bots",NULL},
+ .port = "6667",
+ .ssl = 0
+ }
};
#define SIZEOF_SERVER_LIST (sizeof(server_list)/sizeof(irc_server_conf))