1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:14:46 +02:00

+- Removed SJOIN/SJOIN2 support in SJOIN

+- Fixed a +f bug, found by NiQuiL
+- Applied McSkaf's winlocal.patch, seems to work ok, fixed some problems
+  though in unix/win32 (cptr->fd can be -3. Should fix some READ ERRORS as
+  well. McSkaf, do me a favour and remove all of the C++ comments in the
+  source (//) or modify them to /* */
This commit is contained in:
stskeeps
2001-05-01 15:03:07 +00:00
parent 9f8c142981
commit 4d5d474bbd
19 changed files with 474 additions and 299 deletions
+7 -1
View File
@@ -458,4 +458,10 @@
- Possible fixed a buggie in +f
- Fixed a bug causing Found your hostname (cached) to be displayed 2 times
- Fixed RTLD_NOW problem with openbsd
- Removed SJOIN/SJOIN2 support in SJOIN
- Removed SJOIN/SJOIN2 support in SJOIN
- Fixed a +f bug, found by NiQuiL
- Applied McSkaf's winlocal.patch, seems to work ok, fixed some problems
though in unix/win32 (cptr->fd can be -3. Should fix some READ ERRORS as
well. McSkaf, do me a favour and remove all of the C++ comments in the
source (//) or modify them to /* */
+3
View File
@@ -136,7 +136,10 @@ int create_client(const char *hostname, const int hostport) {
socket_address hostaddr;
int adlen;
/* winlocal
if ((descript=socket(PF_INET, SOCK_STREAM, 0)) < 0)
*/
if ((descript=socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) // winlocal
fatal("socket");
name_to_number(AF_INET, hostname, hostport, &hostaddr, &adlen);
+5
View File
@@ -286,6 +286,11 @@ extern struct SLink *find_user_link( /* struct SLink *, struct Client * */ );
*/
extern int DisplayString(HWND hWnd, char *InBuf, ...);
#undef strerror
// winlocal
#else
typedef int SOCKET;
#define INVALID_SOCKET -1
// winlocal
#endif
#if defined(__FreeBSD__) || defined(__APPLE__)
+3 -3
View File
@@ -816,7 +816,7 @@ struct Client {
long flags; /* client flags */
long umodes; /* client usermodes */
aClient *from; /* == self, if Local Client, *NEVER* NULL! */
int fd; /* >= 0, for local clients */
SOCKET fd; /* >= 0, for local clients */
unsigned char hopcount; /* number of servers to this 0 = local */
short status; /* Client type */
char name[HOSTLEN + 1]; /* Unique name of the client, nick or host */
@@ -858,9 +858,9 @@ struct Client {
u_short receiveB; /* sent and received. */
aClient *listener;
ConfigItem_class *class; /* Configuration record associated */
int authfd; /* fd for rfc931 authentication */
SOCKET authfd; /* fd for rfc931 authentication */
#ifdef SOCKSPORT
int socksfd;
SOCKET socksfd;
#endif
struct IN_ADDR ip; /* keep real ip# too */
u_short port; /* and the remote port# too :-) */
+2 -4
View File
@@ -158,11 +158,9 @@ int deliver_it(aClient *cptr, char *str, int len)
{
writeb[0]++;
# ifndef _WIN32
Debug((DEBUG_ERROR, "write error (%s) to %s",
sys_errlist[errno], cptr->name));
Debug((DEBUG_ERROR, "write error (%s) to %s", sys_errlist[errno], cptr->name));
# else
Debug((DEBUG_ERROR, "write error (%s) to %s",
sys_errlist[WSAGetLastError()], cptr->name));
Debug((DEBUG_ERROR, "write error (%s) to %s", sys_errlist[WSAGetLastError()], cptr->name));
# endif
}
+1 -1
View File
@@ -311,7 +311,7 @@ Membership *make_membership(int local)
Debug((DEBUG_ERROR, "floodmode::freelist gotone"));
}
Debug((DEBUG_ERROR, "floodmode:: bzeroing"));
bzero(&lp2, sizeof(MembershipL));
bzero(lp2, sizeof(MembershipL));
}
if (local)
{
+4
View File
@@ -41,6 +41,7 @@
char *collapse PROTO((char *pattern));
extern aClient *client, *local[];
extern aClient *findlocalbyfd(SOCKET fd);
ID_Copyright("(C) Tony Vincell");
@@ -204,7 +205,10 @@ int crule_via(numargs, crulearg)
acptr = lp->value.cptr;
if (match((char *)crulearg[1], acptr->name))
continue;
/* winlocal
if (match((char *)crulearg[0], (local[acptr->fd])->name))
*/
if (match((char *)crulearg[0], (findlocalbyfd(acptr->fd))->name))
continue;
return (1);
}
+15 -28
View File
@@ -621,22 +621,17 @@ extern TS check_pings(TS currenttime, int check_kills)
#ifdef SHOWCONNECTINFO
if (DoingDNS(cptr))
sendto_one(cptr,
REPORT_FAIL_DNS);
sendto_one(cptr,REPORT_FAIL_DNS);
else if (DoingAuth(cptr))
sendto_one(cptr,
REPORT_FAIL_ID);
sendto_one(cptr,REPORT_FAIL_ID);
#ifdef SOCKSPORT
else
sendto_one(cptr,
REPORT_NO_SOCKS);
sendto_one(cptr,REPORT_NO_SOCKS);
#endif /* SOCKSPORT */
#endif
Debug((DEBUG_NOTICE,
"DNS/AUTH timeout %s",
get_client_name(cptr, TRUE)));
Debug((DEBUG_NOTICE,"DNS/AUTH timeout %s",get_client_name(cptr, TRUE)));
del_queries((char *)cptr);
ClearAuth(cptr);
ClearAuth(cptr);
ClearDNS(cptr);
#ifdef SOCKSPORT
ClearSocks(cptr);
@@ -646,22 +641,15 @@ extern TS check_pings(TS currenttime, int check_kills)
cptr->lasttime = currenttime;
continue;
}
if (IsServer(cptr) || IsConnecting(cptr) ||
IsHandshake(cptr))
if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
{
sendto_realops
("No response from %s, closing link",
get_client_name(cptr, FALSE));
sendto_serv_butone(&me,
":%s GLOBOPS :No response from %s, closing link",
me.name, get_client_name(cptr,
FALSE));
sendto_realops("No response from %s, closing link",get_client_name(cptr, FALSE));
sendto_serv_butone(&me,":%s GLOBOPS :No response from %s, closing link",me.name, get_client_name(cptr,FALSE));
}
exit_client(cptr, cptr, &me, "Ping timeout");
continue;
}
else if (IsRegistered(cptr) &&
((cptr->flags & FLAGS_PINGSENT) == 0))
else if (IsRegistered(cptr) && ((cptr->flags & FLAGS_PINGSENT) == 0))
{
/*
* if we havent PINGed the connection and we havent
@@ -682,10 +670,8 @@ extern TS check_pings(TS currenttime, int check_kills)
* for > 100s, close them.
*/
if (IsUnknown(cptr))
if (cptr->firsttime ? ((TStime() - cptr->firsttime) >
100) : 0)
(void)exit_client(cptr, cptr, &me,
"Connection Timed Out");
if (cptr->firsttime ? ((TStime() - cptr->firsttime) > 100) : 0)
(void)exit_client(cptr, cptr, &me, "Connection Timed Out");
}
/* EXPLANATION
@@ -793,6 +779,8 @@ int InitwIRCD(argc, argv)
(void)umask(077); /* better safe than sorry --SRB */
#else
WSAStartup(wVersionRequested, &wsaData);
for (i = 0; i < MAXCONNECTIONS; ++i) // winlocal
local[i] = NULL; // winlocal
#endif
bzero((char *)&me, sizeof(me));
setup_signals();
@@ -1371,7 +1359,7 @@ void SocketLoop(void *dummy)
}
#endif
Debug((DEBUG_DEBUG, "Got message(s)"));
//Debug((DEBUG_DEBUG, "Got message(s)"));
now = TStime();
/*
** ...perhaps should not do these loops every time,
@@ -1417,8 +1405,7 @@ TS check_fdlists(now)
{
if (!(cptr = local[i]))
continue;
if (IsServer(cptr) || IsListening(cptr)
|| IsOper(cptr) || DoingAuth(cptr))
if (IsServer(cptr) || IsListening(cptr) || IsOper(cptr) || DoingAuth(cptr))
{
busycli_fdlist.entry[++j] = i;
continue;
+3 -3
View File
@@ -131,7 +131,7 @@ aClient *make_client(from, servr)
cptr->serv = NULL;
cptr->srvptr = servr;
cptr->status = STAT_UNKNOWN;
cptr->fd = -1;
cptr->fd = INVALID_SOCKET;
cptr->passwd;
(void)strcpy(cptr->username, "unknown");
if (size == CLIENT_LOCAL_SIZE)
@@ -141,9 +141,9 @@ aClient *make_client(from, servr)
cptr->class = NULL;
cptr->sockhost[0] = '\0';
cptr->buffer[0] = '\0';
cptr->authfd = -1;
cptr->authfd = INVALID_SOCKET;
#ifdef SOCKSPORT
cptr->socksfd = -1;
cptr->socksfd = INVALID_SOCKET;
#endif
}
return (cptr);
+23 -15
View File
@@ -66,7 +66,7 @@ void start_auth(cptr)
#endif
Debug((DEBUG_NOTICE, "start_auth(%x) fd %d status %d",
cptr, cptr->fd, cptr->status));
if ((cptr->authfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
if ((cptr->authfd = socket(AFINET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
#ifdef USE_SYSLOG
syslog(LOG_ERR, "Unable to create auth socket for %s:%m",
@@ -79,15 +79,17 @@ void start_auth(cptr)
ircstp->is_abad++;
return;
}
#ifndef _WIN32
//#ifndef _WIN32 // winlocal
/* winlocal
if (cptr->authfd >= (MAXCONNECTIONS - 3))
*/
if (highest_fd >= (MAXCONNECTIONS - 3))
{
sendto_ops("Can't allocate fd for auth on %s",
get_client_name(cptr, TRUE));
sendto_ops("Can't allocate fd for auth on %s", get_client_name(cptr, TRUE));
(void)close(cptr->authfd);
return;
}
#endif
//#endif // winlocal
#ifdef SHOWCONNECTINFO
sendto_one(cptr, REPORT_DO_ID);
@@ -110,8 +112,8 @@ void start_auth(cptr)
#ifndef _WIN32
sizeof(sock)) == -1 && errno != EINPROGRESS)
#else
sizeof(sock)) == -1 && (WSAGetLastError() !=
WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK))
sizeof(sock)) == SOCKET_ERROR &&
(WSAGetLastError() != WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK))
#endif
{
ircstp->is_abad++;
@@ -123,17 +125,19 @@ void start_auth(cptr)
#else
(void)closesocket(cptr->authfd);
#endif
cptr->authfd = -1;
cptr->authfd = INVALID_SOCKET;
if (!DoingDNS(cptr))
SetAccess(cptr);
#ifdef SHOWCONNECTINFO
sendto_one(cptr, REPORT_FAIL_ID);
sendto_one(cptr, REPORT_FAIL_ID);
#endif
return;
}
cptr->flags |= (FLAGS_WRAUTH | FLAGS_AUTH);
#ifndef _WIN32 // winlocal
if (cptr->authfd > highest_fd)
highest_fd = cptr->authfd;
#endif // winlocal
return;
}
@@ -170,25 +174,26 @@ void send_authports(cptr)
(unsigned int)ntohs(them.SIN_PORT),
(unsigned int)ntohs(us.SIN_PORT));
Debug((DEBUG_SEND, "sending [%s] to auth port %s.113",
authbuf, inetntoa((char *)&them.SIN_ADDR)));
Debug((DEBUG_SEND, "sending [%s] to auth port %s.113",authbuf, inetntoa((char *)&them.SIN_ADDR)));
#ifndef _WIN32
if (write(cptr->authfd, authbuf, strlen(authbuf)) != strlen(authbuf))
#else
if (send(cptr->authfd, authbuf, strlen(authbuf),
0) != (int)strlen(authbuf))
if (send(cptr->authfd, authbuf, strlen(authbuf),0) != (int)strlen(authbuf))
#endif
{
authsenderr:
authsenderr:
ircstp->is_abad++;
#ifndef _WIN32
(void)close(cptr->authfd);
#else
(void)closesocket(cptr->authfd);
#endif
/* winlocal
if (cptr->authfd == highest_fd)
while (!local[highest_fd])
highest_fd--;
*/
removelocalbyfd(cptr->authfd, cptr); // winlocal
cptr->authfd = -1;
cptr->flags &= ~FLAGS_AUTH;
#ifdef SHOWCONNECTINFO
@@ -205,7 +210,7 @@ void send_authports(cptr)
* read_authports
*
* read the reply (if any) from the ident server we connected to.
* The actual read processijng here is pretty weak - no handling of the reply
* The actual read processing here is pretty weak - no handling of the reply
* if it is fragmented by IP.
*/
void read_authports(cptr)
@@ -269,9 +274,12 @@ void read_authports(cptr)
#else
(void)closesocket(cptr->authfd);
#endif
/* winlocal
if (cptr->authfd == highest_fd)
while (!local[highest_fd])
highest_fd--;
*/
removelocalbyfd(cptr->authfd, cptr);
cptr->count = 0;
cptr->authfd = -1;
ClearAuth(cptr);
+162 -29
View File
@@ -94,7 +94,17 @@ int rr;
extern char backupbuf[8192];
aClient *local[MAXCONNECTIONS];
/* winlocal
int highest_fd = 0, readcalls = 0, resfd = -1;
*/
#ifdef _WIN32
// first 3 fd's reserved for stdin, stdout, stderror
SOCKET highest_fd = 2; // winlocal
#else
// the *NIX version takes care of the standard streams
SOCKET highest_fd = 0; // winlocal
#endif
int readcalls = 0, resfd = -1;
static struct SOCKADDR_IN mysk;
static struct SOCKADDR *connect_inet PROTO((ConfigItem_link *, aClient *, int *));
@@ -137,6 +147,89 @@ extern fdlist socks_fdlist;
# endif
#endif
/* winlocal
** addlocal()
*/
int addlocal(SOCKET fd, aClient *paClient)
{
// highest_fd = number of entries in local[] minus one
// range is 0 to MAXCONNECTIONS-1, local[0-2] are not used
#ifdef _WIN32
if (highest_fd >= MAXCONNECTIONS-1)
return 0;
local[++highest_fd] = paClient;
#else
local[fd] = paClient;
if (fd > highest_fd)
highest_fd = fd;
#endif
return 1;
}
/* winlocal
** removelocalbyindex()
*/
int removelocalbyindex(SOCKET fd, aClient *paClient)
{
#ifdef _WIN32
if (fd > highest_fd)
return 0;
if (fd != highest_fd)
local[fd] = local[highest_fd];
local[highest_fd] = NULL;
--highest_fd;
#else
if (fd == highest_fd)
while (!local[highest_fd])
--highest_fd;
#endif
return 1;
}
/* winlocal
** removelocalbyfd()
*/
int removelocalbyfd(SOCKET fd, aClient *paClient)
{
SOCKET i;
#ifdef _WIN32
// socket and auth fd's don't take up separate entries
if (paClient->socksfd == fd || paClient->authfd == fd)
return 1;
for (i = highest_fd; i > 2; --i)
if (local[i] && local[i]->fd == fd)
{
if (i != highest_fd)
local[i] = local[highest_fd];
local[highest_fd] = NULL;
--highest_fd;
return 1;
}
return 0;
#else
if (fd == highest_fd)
while (!local[highest_fd])
--highest_fd;
#endif
return 1;
}
/* winlocal
** findlocalbyfd()
*/
aClient *findlocalbyfd(SOCKET fd)
{
SOCKET i;
#ifdef _WIN32
for (i = highest_fd; i > 2; --i)
if (local[i] && local[i]->fd == fd)
return local[i];
return NULL;
#else
return local[fd];
#endif
}
/*
** add_local_domain()
** Add the domain to hostname, if it is missing
@@ -298,10 +391,16 @@ int inetport(cptr, name, port)
/*
* At first, open a new socket
*/
/* winlocal
if (cptr->fd == -1)
*/
if (cptr->fd == INVALID_SOCKET)
cptr->fd = socket(AFINET, SOCK_STREAM, 0);
/* winlocal
if (cptr->fd < 0)
*/
if (cptr->fd == INVALID_SOCKET)
{
#if !defined(DEBUGMODE) && !defined(_WIN32)
#endif
@@ -375,9 +474,10 @@ int inetport(cptr, name, port)
ntohs(server.SIN_PORT));
(void)write(0, buf, strlen(buf));
}
#ifndef _WIN32 // winlocal
if (cptr->fd > highest_fd)
highest_fd = cptr->fd;
#endif // winlocal
#ifdef INET6
bcopy(server.sin6_addr.s6_addr, cptr->ip.s6_addr, IN6ADDRSZ);
#else
@@ -385,7 +485,8 @@ int inetport(cptr, name, port)
#endif
cptr->port = (int)ntohs(server.SIN_PORT);
(void)listen(cptr->fd, LISTEN_SIZE);
local[cptr->fd] = cptr;
// local[cptr->fd] = cptr; // winlocal
addlocal(cptr->fd, cptr); // winlocal
return 0;
}
@@ -942,7 +1043,8 @@ void close_connection(cptr)
if (cptr->fd >= 0)
{
flush_connections(cptr->fd);
local[cptr->fd] = NULL;
// local[cptr->fd] = NULL; // winlocal
removelocalbyfd(cptr->fd, cptr); // winlocal
#ifndef _WIN32
(void)close(cptr->fd);
#else
@@ -953,9 +1055,11 @@ void close_connection(cptr)
DBufClear(&cptr->recvQ);
}
/* winlocal - this isn't necessary anymore
for (; highest_fd > 0; highest_fd--)
if (local[highest_fd])
break;
*/
cptr->from = NULL; /* ...this should catch them! >:) --msa */
@@ -964,8 +1068,7 @@ void close_connection(cptr)
*/
#ifdef DO_REMAPPING
if (empty > 0)
if ((j = highest_fd) > (i = empty) &&
(local[j]->status != STAT_LOG))
if ((j = highest_fd) > (i = empty) && (local[j]->status != STAT_LOG))
{
if (dup2(j, i) == -1)
return;
@@ -1009,7 +1112,8 @@ void close_connection(cptr)
}
#endif
while (!local[highest_fd])
highest_fd--;
// highest_fd--; // winlocal
removelocalbyindex(highest_fd, NULL); // winlocal
return;
}
@@ -1301,9 +1405,12 @@ aClient *add_connection(cptr, fd)
}
acptr->fd = fd;
/* winlocal
if (fd > highest_fd)
highest_fd = fd;
local[fd] = acptr;
*/
addlocal(fd, acptr); // winlocal
acptr->listener = cptr;
if (!acptr->listener->class)
{
@@ -1665,7 +1772,8 @@ int read_message(delay, listp)
continue;
if (IsLog(cptr))
continue;
if (!(cptr->fd > 0))
continue;
#ifdef SOCKSPORT
if (DoingSocks(cptr))
{
@@ -1698,20 +1806,21 @@ int read_message(delay, listp)
continue;
if (IsMe(cptr) && IsListening(cptr))
{
FD_SET(i, &read_set);
FD_SET(cptr->fd, &read_set); // winlocal
}
else if (!IsMe(cptr))
{
if (DBufLength(&cptr->recvQ) && delay2 > 2)
delay2 = 1;
if (DBufLength(&cptr->recvQ) < 4088)
FD_SET(i, &read_set);
if ((DBufLength(&cptr->recvQ) < 4088))
FD_SET(cptr->fd, &read_set); // winlocal
}
if (DBufLength(&cptr->sendQ) || IsConnecting(cptr) ||
(DoList(cptr) && IsSendable(cptr)))
FD_SET(i, &write_set);
FD_SET(cptr->fd, &write_set); // winlocal
}
#ifdef SOCKSPORT
@@ -1767,10 +1876,11 @@ int read_message(delay, listp)
int tmpsock;
tmpsock = accept(me.socksfd, NULL, NULL);
if (tmpsock >= 0)
#ifdef _WIN32
if (tmpsock != SOCKET_ERROR)
closesocket(tmpsock);
#else
if (tmpsock >= 0)
close(tmpsock);
#endif /* _WIN32 */
FD_CLR(me.socksfd, &read_set);
@@ -1816,9 +1926,12 @@ int read_message(delay, listp)
{
ircstp->is_abad++;
closesocket(cptr->authfd);
/* winlocal
if (cptr->authfd == highest_fd)
while (!local[highest_fd])
highest_fd--;
*/
removelocalbyfd(cptr->authfd, cptr); // winlocal
cptr->authfd = -1;
cptr->flags &= ~(FLAGS_AUTH | FLAGS_WRAUTH);
if (!DoingDNS(cptr))
@@ -1867,9 +1980,12 @@ int read_message(delay, listp)
{
ircstp->is_abad++;
closesocket(cptr->socksfd);
/* winlocal
if (cptr->socksfd == highest_fd)
while (!local[highest_fd])
highest_fd--;
*/
removelocalbyfd(cptr->socksfd, cptr); // winlocal
cptr->socksfd = -1;
cptr->flags &= ~(FLAGS_SOCKS | FLAGS_WRSOCKS);
if (nfds > 0)
@@ -1892,10 +2008,10 @@ int read_message(delay, listp)
#endif /* SOCKSPORT */
for (i = highest_fd; i >= 0; i--)
if ((cptr = local[i]) && FD_ISSET(i, &read_set) &&
if ((cptr = local[i]) && (cptr->fd >= 0) && FD_ISSET(cptr->fd, &read_set) &&
IsListening(cptr))
{
FD_CLR(i, &read_set);
FD_CLR(cptr->fd, &read_set);
nfds--;
cptr->lasttime = TStime();
/*
@@ -1909,14 +2025,20 @@ int read_message(delay, listp)
** point, just assume that connections cannot
** be accepted until some old is closed first.
*/
if ((fd = accept(i, NULL, NULL)) < 0)
#ifndef _WIN32
if ((fd = accept(cptr->fd, NULL, NULL)) < 0)
#else
if ((fd = accept(cptr->fd, NULL, NULL)) == INVALID_SOCKET)
#endif
{
report_error("Cannot accept connections %s:%s",
cptr);
report_error("Cannot accept connections %s:%s", cptr);
break;
}
ircstp->is_ac++;
/* winlocal
if (fd >= MAXCLIENTS)
*/
if (highest_fd >= MAXCLIENTS) // winlocal
{
ircstp->is_ref++;
sendto_ops("All connections in use. (%s)",
@@ -1950,7 +2072,7 @@ int read_message(delay, listp)
if (!(cptr = local[i]) || IsMe(cptr))
continue;
if (FD_ISSET(i, &write_set))
if ((cptr->fd >= 0) && FD_ISSET(cptr->fd, &write_set))
{
int write_err = 0;
nfds--;
@@ -1970,10 +2092,10 @@ int read_message(delay, listp)
if (IsDead(cptr) || write_err)
{
deadsocket:
if (FD_ISSET(i, &read_set))
if (FD_ISSET(cptr->fd, &write_set)) // winlocal
{
nfds--;
FD_CLR(i, &read_set);
FD_CLR(cptr->fd, &read_set); // winlocal
}
(void)exit_client(cptr, cptr, &me,
((sockerr = get_sockerr(cptr))
@@ -1981,14 +2103,17 @@ int read_message(delay, listp)
continue;
}
}
if (cptr->fd < 0)
continue;
length = 1; /* for fall through case */
if (!NoNewLine(cptr) || FD_ISSET(i, &read_set))
if (!NoNewLine(cptr) || FD_ISSET(cptr->fd, &read_set))
length = read_packet(cptr, &read_set);
if (length > 0)
flush_connections(i);
flush_connections(cptr->fd);
if ((length != FLUSH_BUFFER) && IsDead(cptr))
goto deadsocket;
if (!FD_ISSET(i, &read_set) && length > 0)
if ((cptr->fd >= 0) && !FD_ISSET(cptr->fd, &read_set) && length > 0)
continue;
nfds--;
readcalls++;
@@ -2241,7 +2366,7 @@ int read_message(delay, listp)
int tmpsock;
nfds--;
tmpsock = accept(me.socksfd, NULL, NULL);
if (tmpsock >= 0)
if (tmpsock != INVALID_SOCKET)
close(tmpsock);
}
@@ -2308,10 +2433,9 @@ int read_message(delay, listp)
** point, just assume that connections cannot
** be accepted until some old is closed first.
*/
if ((fd = accept(fd, NULL, NULL)) < 0)
if ((fd = accept(fd, NULL, NULL)) == INVALID_SOCKET)
{
report_error("Cannot accept connections %s:%s",
cptr);
report_error("Cannot accept connections %s:%s", cptr);
break;
}
ircstp->is_ac++;
@@ -2483,7 +2607,7 @@ int connect_server(aconf, by, hp)
{
errtmp = errno; /* other system calls may eat errno */
#else
if (connect(cptr->fd, svp, len) < 0 &&
if (connect(cptr->fd, svp, len) == SOCKET_ERROR &&
WSAGetLastError() != WSAEINPROGRESS &&
WSAGetLastError() != WSAEWOULDBLOCK)
{
@@ -2534,9 +2658,12 @@ int connect_server(aconf, by, hp)
cptr->serv->user = NULL;
}
cptr->serv->up = me.name;
/* winlocal
if (cptr->fd > highest_fd)
highest_fd = cptr->fd;
local[cptr->fd] = cptr;
*/
addlocal(cptr->fd, cptr); // winlocal
cptr->listener = &me;
SetConnecting(cptr);
IRCstats.unknown++;
@@ -2559,7 +2686,10 @@ static struct SOCKADDR *connect_inet(aconf, cptr, lenp)
* with it so if it fails its useless.
*/
cptr->fd = socket(AFINET, SOCK_STREAM, 0);
/* winlocal
if (cptr->fd >= MAXCLIENTS)
*/
if (cptr->fd == INVALID_SOCKET || highest_fd >= MAXCLIENTS)
{
sendto_realops("No more connections allowed (%s)", cptr->name);
return NULL;
@@ -2569,7 +2699,10 @@ static struct SOCKADDR *connect_inet(aconf, cptr, lenp)
server.SIN_FAMILY = AFINET;
get_sockhost(cptr, aconf->hostname);
/* winlocal
if (cptr->fd == -1)
*/
if (cptr->fd == INVALID_SOCKET) // winlocal
{
report_error("opening stream socket to server %s:%s", cptr);
return NULL;
@@ -2757,7 +2890,7 @@ void do_dns_async(id)
if (hp && aconf)
bcopy(hp->h_addr, (char *)&aconf->ipnum,
sizeof(struct IN_ADDR));
break;
break;
default :
break;
}
+4 -1
View File
@@ -175,7 +175,10 @@ aTKline *tkl_expire(aTKline * tmp)
{
for (i1 = 0; i1 <= 5; i1++)
{
for (i = 0; i <= (MAXCONNECTIONS - 1); i++)
/* winlocal
for (i = 0; i <= (MAXCONNECTIONS - 1); i++)
*/
for (i = 0; i <= highest_fd; ++i)
{
if (acptr = local[i])
if (MyClient(acptr) && IsShunned(acptr))
+17 -3
View File
@@ -70,7 +70,10 @@ void init_socks(aClient *cptr)
socksid[3] = LOCHAR(sport);
socksid[8] = 0;
/* winlocal
if ((cptr->socksfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
*/
if ((cptr->socksfd = socket(AFINET, SOCK_STREAM, 0)) == INVALID_SOCKET) // winlocal
return;
set_non_blocking(cptr->socksfd, cptr);
@@ -114,7 +117,10 @@ void start_socks(cptr)
struct SOCKADDR_IN sin;
int sinlen = sizeof(struct SOCKADDR_IN);
/* winlocal
if ((cptr->socksfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
*/
if ((cptr->socksfd = socket(AFINET, SOCK_STREAM, 0)) == INVALID_SOCKET) // winlocal
{
Debug((DEBUG_ERROR, "Unable to create socks socket for %s:%s",
get_client_name(cptr, TRUE), strerror(get_sockerr(cptr))));
@@ -151,8 +157,8 @@ void start_socks(cptr)
#ifndef _WIN32
sinlen) == -1 && errno != EINPROGRESS)
#else
sinlen) == -1 && (WSAGetLastError() !=
WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK))
sinlen) == SOCKET_ERROR &&
(WSAGetLastError() != WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK))
#endif
{
/* we have no socks server! */
@@ -161,15 +167,17 @@ void start_socks(cptr)
#else
closesocket(cptr->socksfd);
#endif
cptr->socksfd = -1;
cptr->socksfd = INVALID_SOCKET;
#ifdef SHOWCONNECTINFO
sendto_one(cptr, REPORT_NO_SOCKS);
#endif
return;
}
cptr->flags |= (FLAGS_WRSOCKS | FLAGS_SOCKS);
#ifndef _WIN32 // winlocal
if (cptr->socksfd > highest_fd)
highest_fd = cptr->socksfd;
#endif // winlocal
return;
skip_socks:
@@ -217,9 +225,12 @@ void send_socksquery(cptr)
#else
closesocket(cptr->socksfd);
#endif
/* winlocal
if (cptr->socksfd == highest_fd)
while (!local[highest_fd])
highest_fd--;
*/
removelocalbyfd(cptr->socksfd, cptr); // winlocal
cptr->socksfd = -1;
cptr->flags &= ~FLAGS_SOCKS;
#ifdef SHOWCONNECTINFO
@@ -249,9 +260,12 @@ void read_socks(cptr)
#else
(void)closesocket(cptr->socksfd);
#endif
/* winlocal
if (cptr->socksfd == highest_fd)
while (!local[highest_fd])
highest_fd--;
*/
removelocalbyfd(cptr->socksfd, cptr); // winlocal
cptr->socksfd = -1;
ClearSocks(cptr);
+7 -15
View File
@@ -2909,8 +2909,7 @@ int m_whois(cptr, sptr, parc, parv)
showperson = 1;
break;
}
if (!invis && HiddenChannel(chptr) &&
!SecretChannel(chptr))
if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr))
showperson = 1;
else if (IsAnOper(sptr) && SecretChannel(chptr))
{
@@ -2956,21 +2955,15 @@ int m_whois(cptr, sptr, parc, parv)
user->realhost);
}
if (IsARegNick(acptr))
sendto_one(sptr, rpl_str(RPL_WHOISREGNICK),
me.name, parv[0], name);
sendto_one(sptr, rpl_str(RPL_WHOISREGNICK), me.name, parv[0], name);
found = 1;
mlen = strlen(me.name) + strlen(parv[0]) + 6 +
strlen(name);
for (len = 0, *buf = '\0', lp = user->channel; lp;
lp = lp->next)
mlen = strlen(me.name) + strlen(parv[0]) + 6 + strlen(name);
for (len = 0, *buf = '\0', lp = user->channel; lp; lp = lp->next)
{
chptr = lp->chptr;
if (!IsServices(sptr) && (IsAnOper(sptr)
|| ShowChannel(sptr, chptr)
|| (acptr == sptr)))
if (!invis && !IsServices(sptr) && (IsAnOper(sptr) || ShowChannel(sptr, chptr) || (acptr == sptr)))
{
if (len + strlen(chptr->chname)
> (size_t)BUFSIZE - 4 - mlen)
if (len + strlen(chptr->chname) > (size_t)BUFSIZE - 4 - mlen)
{
sendto_one(sptr,
":%s %d %s %s :%s",
@@ -3010,8 +3003,7 @@ int m_whois(cptr, sptr, parc, parv)
}
if (buf[0] != '\0')
sendto_one(sptr, rpl_str(RPL_WHOISCHANNELS),
me.name, parv[0], name, buf);
sendto_one(sptr, rpl_str(RPL_WHOISCHANNELS), me.name, parv[0], name, buf);
sendto_one(sptr, rpl_str(RPL_WHOISSERVER),
me.name, parv[0], name, user->server,
+5
View File
@@ -41,6 +41,8 @@ static char sccsid[] =
void vsendto_one(aClient *to, char *pattern, va_list vl);
void sendbufto_one(aClient *to);
aClient *findlocalbyfd(SOCKET fd); // winlocal
extern int sendanyways;
#ifndef NO_FDLIST
extern fdlist serv_fdlist;
@@ -122,7 +124,10 @@ void flush_connections(fd)
&& DBufLength(&cptr->sendQ) > 0)
send_queued(cptr);
}
/* winlocal
else if (fd >= 0 && (cptr = local[fd]) && !(cptr->flags & FLAGS_BLOCKED)
*/
else if (fd >= 0 && (cptr = findlocalbyfd(fd)) && !(cptr->flags & FLAGS_BLOCKED) // winlocal
&& DBufLength(&cptr->sendQ) > 0)
send_queued(cptr);
+129 -129
View File
@@ -1,129 +1,129 @@
typedef struct {
unsigned int CurrLoclUsers;
unsigned int CurrGlobUsers;
unsigned int MaxLoclUsers;
unsigned int MaxGlobUsers;
unsigned int NumUsers; // Eh ??
unsigned int Invisible;
unsigned int connections;
unsigned int NumIRCops;
unsigned int LocalClients; // Eh??
unsigned int LocalServers;
unsigned int chans;
unsigned int Servers;
/* ToBe Added
int TSsync stuff .... dont know what yet
*/
} WINSTATS, *pWINSTATS;
typedef struct RichLine
{
BYTE *Data;
WORD Len;
struct RichLine *Prev, *Next;
} aRichLine;
typedef struct AllRichLines
{
aRichLine *First, *Current;
int NumLines;
} INFRICHLINE;
/**********************************************************
********** Graphy Header (C) David Flynn 2000 ************/
#define SS_NORM 0x0001 // spincube window styles
#define SS_SLOW 0x0002
#define SS_FAST 0x0003
#define CCHSTYLE 20 // size of style string, i.e. "SS_ERASE"
#define NUM_GRAPH_STYLES 2
#define GRAPH_EXTRA 4 // number of extra bytes for spincube class
#define IDS_REGCLASSFAIL 16
#define IDS_UNREGFAIL 17
#define IDS_DLGBOXFAIL 18
#define IDS_ALLOCFAIL 19
#define IDS_CREATEDCFAIL 20
#define IDS_CREATEBITMAPFAIL 21
#define GWL_GRAPHDATA 0
// offset of control's instance data
#define GRAPHCLASS "Graph"
#define GRAPHDESCRIPTION "An animated control"
#define GRAPHDEFAULTTEXT ":-)"
#define GRAPH_EVENT 1
#define UPDATE_TIMER 2
#define UPDATE_INTERVAL /*60000*/ 30
typedef struct
{
HDC hdcCompat; // the DC that will contain our off-screen
// image
//HBITMAP hbmSave; // Save previous selected bitmap
//HBITMAP hbmCompat; // The bitmap that will contain the actual
// image, i.e. we will always do our
// drawing on this bmp & then blt the
// result to the screen.
BOOL InitDraw; //Did we draw once yet?
int width; // Width of monitor (= size of history)
int cpupointer; // pointer to cpu history
HDC DCBack;
HBITMAP BMBack;
HBITMAP OldBack;
HDC DCDblBuff;
HBITMAP BMDblBuff;
HBITMAP OldDblBuff;
HBITMAP Background;
HBITMAP CPUMap;
SIZE WindowSize;
BOOL Border;
BOOL Grid;
COLORREF BorderColor;
COLORREF BackColor;
COLORREF GridColor;
COLORREF CPUColor;
COLORREF AVGCPUColor;
COLORREF MEMColor;
char cpuhistory[2048];
char BackgroundPath[256];
char CPUMapPath[256];
int iOptions; // Contains the current options for this
// ctrl, i.e. erase background.
} GRAPHINFO, *PGRAPHINFO;
/******************************************************************************\
* FUNCTION PROTOTYPES
\******************************************************************************/
LRESULT CALLBACK GraphWndProc (HWND, UINT, WPARAM, LPARAM);
DWORD Reserved,dataType,dataLen=8192;
// DoubleBuffer Stuff
void DrawMonitor(HDC hdc, RECT r,HWND);
void CreateDblBuff(HWND);
void FreeDblBuff(void);
typedef struct {
unsigned int CurrLoclUsers;
unsigned int CurrGlobUsers;
unsigned int MaxLoclUsers;
unsigned int MaxGlobUsers;
unsigned int NumUsers; // Eh ??
unsigned int Invisible;
unsigned int connections;
unsigned int NumIRCops;
unsigned int LocalClients; // Eh??
unsigned int LocalServers;
unsigned int chans;
unsigned int Servers;
/* ToBe Added
int TSsync stuff .... dont know what yet
*/
} WINSTATS, *pWINSTATS;
typedef struct RichLine
{
BYTE *Data;
WORD Len;
struct RichLine *Prev, *Next;
} aRichLine;
typedef struct AllRichLines
{
aRichLine *First, *Current;
int NumLines;
} INFRICHLINE;
/**********************************************************
********** Graphy Header (C) David Flynn 2000 ************/
#define SS_NORM 0x0001 // spincube window styles
#define SS_SLOW 0x0002
#define SS_FAST 0x0003
#define CCHSTYLE 20 // size of style string, i.e. "SS_ERASE"
#define NUM_GRAPH_STYLES 2
#define GRAPH_EXTRA 4 // number of extra bytes for spincube class
#define IDS_REGCLASSFAIL 16
#define IDS_UNREGFAIL 17
#define IDS_DLGBOXFAIL 18
#define IDS_ALLOCFAIL 19
#define IDS_CREATEDCFAIL 20
#define IDS_CREATEBITMAPFAIL 21
#define GWL_GRAPHDATA 0
// offset of control's instance data
#define GRAPHCLASS "Graph"
#define GRAPHDESCRIPTION "An animated control"
#define GRAPHDEFAULTTEXT ":-)"
#define GRAPH_EVENT 1
#define UPDATE_TIMER 2
#define UPDATE_INTERVAL /*60000*/ 30
typedef struct
{
HDC hdcCompat; // the DC that will contain our off-screen
// image
//HBITMAP hbmSave; // Save previous selected bitmap
//HBITMAP hbmCompat; // The bitmap that will contain the actual
// image, i.e. we will always do our
// drawing on this bmp & then blt the
// result to the screen.
BOOL InitDraw; //Did we draw once yet?
int width; // Width of monitor (= size of history)
int cpupointer; // pointer to cpu history
HDC DCBack;
HBITMAP BMBack;
HBITMAP OldBack;
HDC DCDblBuff;
HBITMAP BMDblBuff;
HBITMAP OldDblBuff;
HBITMAP Background;
HBITMAP CPUMap;
SIZE WindowSize;
BOOL Border;
BOOL Grid;
COLORREF BorderColor;
COLORREF BackColor;
COLORREF GridColor;
COLORREF CPUColor;
COLORREF AVGCPUColor;
COLORREF MEMColor;
char cpuhistory[2048];
char BackgroundPath[256];
char CPUMapPath[256];
int iOptions; // Contains the current options for this
// ctrl, i.e. erase background.
} GRAPHINFO, *PGRAPHINFO;
/******************************************************************************\
* FUNCTION PROTOTYPES
\******************************************************************************/
LRESULT CALLBACK GraphWndProc (HWND, UINT, WPARAM, LPARAM);
DWORD Reserved,dataType,dataLen=8192;
// DoubleBuffer Stuff
void DrawMonitor(HDC hdc, RECT r,HWND);
void CreateDblBuff(HWND);
void FreeDblBuff(void);
+55 -55
View File
@@ -1,55 +1,55 @@
/*
*
* A helper program for the compilation process
*
*/
/* x,y,z,w
* | | | `-- private build
* | | `---- release build
* | `------ minor version
* `-------- major version
*/
#include <stdio.h>
void main(int argc,char *argv[])
{
FILE *openme;
char inbuf[512];
int i,pb=0,rb=0,mi=0,ma=0;
if (argc == 1)
exit(-1);
if ((openme = fopen(argv[1],"r+"))==NULL)
{
printf("error\n");
exit(-1);
}
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&pb); /*Read Buffer*/
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&rb);
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&mi);
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&ma);
pb++;
if (argc > 2)
if (atoi(argv[2])==0) /*Public Build*/
rb++;
printf("new version = %d,%d,%d,%d",ma,mi,rb,pb);
rewind(openme);
fprintf(openme,"#define pb %d\n",pb); /*Write Buffer*/
fprintf(openme,"#define rb %d\n",rb);
fprintf(openme,"#define mi %d\n",mi);
fprintf(openme,"#define ma %d\n",ma);
fprintf(openme,"#define vFILEVERSION ma,mi,rb,pb\n#define vPRODUCTVERSION ma,mi,0,0\n#define vDISPFILEVERSION \"%d,%d,%d,%d\\0\"\n#define vSUBBUILD \"%d\\0\"\n",ma,mi,rb,pb,pb);
fclose(openme);
}
/*
*
* A helper program for the compilation process
*
*/
/* x,y,z,w
* | | | `-- private build
* | | `---- release build
* | `------ minor version
* `-------- major version
*/
#include <stdio.h>
void main(int argc,char *argv[])
{
FILE *openme;
char inbuf[512];
int i,pb=0,rb=0,mi=0,ma=0;
if (argc == 1)
exit(-1);
if ((openme = fopen(argv[1],"r+"))==NULL)
{
printf("error\n");
exit(-1);
}
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&pb); /*Read Buffer*/
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&rb);
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&mi);
fscanf(openme,"%s %s %d\n",inbuf,inbuf,&ma);
pb++;
if (argc > 2)
if (atoi(argv[2])==0) /*Public Build*/
rb++;
printf("new version = %d,%d,%d,%d",ma,mi,rb,pb);
rewind(openme);
fprintf(openme,"#define pb %d\n",pb); /*Write Buffer*/
fprintf(openme,"#define rb %d\n",rb);
fprintf(openme,"#define mi %d\n",mi);
fprintf(openme,"#define ma %d\n",ma);
fprintf(openme,"#define vFILEVERSION ma,mi,rb,pb\n#define vPRODUCTVERSION ma,mi,0,0\n#define vDISPFILEVERSION \"%d,%d,%d,%d\\0\"\n#define vSUBBUILD \"%d\\0\"\n",ma,mi,rb,pb,pb);
fclose(openme);
}
+9 -9
View File
@@ -1,9 +1,9 @@
#define pb 1
#define rb 4
#define mi 1
#define ma 3
#define vFILEVERSION ma,mi,rb,pb
#define vPRODUCTVERSION ma,mi,0,0
#define vDISPFILEVERSION "3,1,4,1\0"
#define vSUBBUILD "1\0"
\0"
#define pb 5
#define rb 4
#define mi 1
#define ma 3
#define vFILEVERSION ma,mi,rb,pb
#define vPRODUCTVERSION ma,mi,0,0
#define vDISPFILEVERSION "3,1,4,5\0"
#define vSUBBUILD "5\0"
\0"
+20 -3
View File
@@ -1,16 +1,33 @@
Changed
To do win32 compiling
- Copy include/win32/setup.h to include/
- Modify config.h to suit you
- Modify config.h to suit you
- Make settings.h to suit you
- unzip src/win32/unrealircd.bmp.gz using your favorite program to the src/win32 dir
- From the root dir of unreal and in a command prompt (where the make file is) run 'nmake makefile.win32'
UnrealIRCd is not absolute to compile on Win32 yet
Secondly, there has been a small problem with the fact that many users have been unsuccessful in compiling the wIRCd using MSVC 6 ... the problem is that as Unreal is a GUI, the header files that come with VC6 are out of date and need updating, as the header files in use are from the original win95 release sort of time, even though the code is compatable, things have moved on in the way of controlls so to compile it you will want to download the Jan2000 Platform SDK from ftp.microsoft.com/developr/platformsdk/jan2000/ you will want to probabaly down load the whole lot, but its a wee bit big (over 500mb for the x86 version) i will be looking up which cab files you will neeed, alternitivley you can try to contact M$ and i am sure that for the price to cover p&p or the CD they will send you it all ... if you are a real diplomat you will talk them into sending it and all the other updates to you for free. Really to compare with the *nix world, its like trying to compile something that requires a later kernel than you have, or that your glibc is xhundred years old =).
Secondly, there has been a small problem with the fact that many
users have been unsuccessful in compiling the wIRCd using MSVC 6 ...
the problem is that as Unreal is a GUI, the header files that come
with VC6 are out of date and need updating, as the header files in
use are from the original win95 release sort of time, even though the
code is compatable, things have moved on in the way of controlls so
to compile it you will want to download the Jan2000 Platform SDK from
ftp.microsoft.com/developr/platformsdk/jan2000/ you will want to
probabaly down load the whole lot, but its a wee bit big (over 500mb
for the x86 version) i will be looking up which cab files you will
neeed, alternitivley you can try to contact M$ and i am sure that for
the price to cover p&p or the CD they will send you it all ... if you
are a real diplomat you will talk them into sending it and all the
other updates to you for free. Really to compare with the *nix
world, its like trying to compile something that requires a later
kernel than you have, or that your glibc is xhundred years old =).
If you have any problems with that, dont understand what on earth i am going on about then do contact me on either #unrealircd on irc.ircsystems.net or you can e-mail me on this list.
If you have any problems with that, dont understand what on earth i
am going on about then do contact me on either #unrealircd on
irc.ircsystems.net or you can e-mail me on this list.
DrBin (Dave)
drbin@tspre.org