1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Remote includes HTTP scheme */
18 using irc::sockets::OpenTCPSocket;
20 class ModuleRemoteIncludeHttp : public Module
24 ModuleRemoteIncludeHttp(InspIRCd* Me)
27 // The constructor just makes a copy of the server class
30 Implementation eventlist[] = { I_OnDownloadFile };
31 ServerInstance->Modules->Attach(eventlist, this, 1);
34 virtual ~ModuleRemoteIncludeHttp()
38 virtual int OnDownloadFile(const std::string &filename, std::istream* &filedata)
40 ServerInstance->Log(DEBUG,"OnDownloadFile in m_remoteinclude_http");
41 int sockfd, portno, n;
42 struct sockaddr_in serv_addr;
43 struct hostent *server;
47 server = gethostbyname("neuron.brainbox.winbot.co.uk");
49 sockfd = socket(AF_INET, SOCK_STREAM, 0);
56 memset(&serv_addr, sizeof(serv_addr), 0);
58 serv_addr.sin_family = AF_INET;
60 memcpy(server->h_addr, &serv_addr.sin_addr.s_addr, server->h_length);
61 serv_addr.sin_port = htons(portno);
63 if (connect(sockfd, (const sockaddr*)&serv_addr, sizeof(serv_addr)) < 0)
66 n = send(sockfd, "GET / HTTP/1.0\r\n", 16, 0);
70 n = read(sockfd,buffer,255);
78 virtual Version GetVersion()
80 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
85 MODULE_INIT(ModuleRemoteIncludeHttp)