-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttpauth.c
More file actions
39 lines (34 loc) · 1.04 KB
/
httpauth.c
File metadata and controls
39 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/////////////////////////////////////////////////////////////////////////////
//
// http.c
//
// MiniWeb HTTP authentication implementation
//
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "httppil.h"
#include "httpapi.h"
#include "httpint.h"
#ifdef HTTPAUTH
extern HttpParam g_httpParam;
////////////////////////////////////////////////////////////////////////////
// _mwCheckAuthentication
// Check if a connected peer is authenticated
////////////////////////////////////////////////////////////////////////////
BOOL _mwCheckAuthentication(HttpSocket* phsSocket)
{
if (!ISFLAGSET(phsSocket,FLAG_AUTHENTICATION))
return TRUE;
if (g_httpParam.dwAuthenticatedNode!=phsSocket->ipAddr.laddr) {
// Not authenticated
g_httpParam.stats.authFailCount++;
return FALSE;
}
// Extend authentication period
g_httpParam.tmAuthExpireTime = time(NULL) + HTTPAUTHTIMEOUT;
return TRUE;
}
#endif