⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s5authserver.h

📁 ss5的socks5认扩展认证模块,实现了基本了认证功能,需要的话,可以进行功能增强扩展. 已在Linux下测试通过.
💻 H
字号:
/* * *  File  : S5AuthServer.h *  Author: NieJun *  Mail  : yhniejun@163.com *  Date  : 2008/10/20 * */#ifndef _S5AuthServer_H#define _S5AuthServer_H#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <string.h>#include <pthread.h>#include <netinet/in.h>#include <sys/socket.h>#include <arpa/inet.h>#include <sys/types.h>#include <sys/stat.h>#include <mysql/mysql.h>#include <sys/select.h>#include <sys/time.h>#include <pthread.h>#define MAIN_DEBUG_INFO//#define HASH_AUTH_MODE#define AuthTrue           1#define AuthFalse          0#define S5AuthAddr         "0.0.0.0"#define S5AuthPort         1898#define MAX_USER_TBL       1000000#define MAX_BUFFER_SIZE    1024#define MAX_CONNICTION     10#define MAX_AUTH_CMD_LEN   128#define MAX_NAME_LEN       64#define MAX_PASSWD_LEN     64#define AUTH_HASH_MODE     1#define AUTH_DATABASE_MODE 2#define VERSION            "0.1.0"#define APP_NAME           "S5AuthServer"#define SYS_AUTHOR         "Nie Jun"#define DEF_CONF_FILE      "/etc/s5auth/s5auth.conf"#define DEF_LOG_FILE       "/var/log/s5auth/s5auth.log"/***************************** Auth cmd define ********************************/#define AUTH_OPTION_SIZE          0x02        //命令请求中的动作位长度的字节数#define AUTH_NAME_LEN_SIZE        0x01        //命令请求中标识名字长度位的字节数#define AUTH_PASSWD_LEN_SIZE      0X01        //命令请求中标识密码长度位的字节数//Auth request cmd define#define AUTH_LOGIN                0x0101      //请求登录#define AUTH_LOGOUT               0x0102      //请求登出#define AUTH_CANCEL               0x0103      //请求注销//Auth error code define#define ERROR_ACCOUNT_NOT_FOUND   0x0201      //没有此帐号#define ERROR_PASSWORD_INCORRECT  0x0202      //登录密码不对#define ERROR_USER_ARREARS        0x0203      //帐号已欠费#define ERROR_ACCOUNT_FREEZE      0x0204      //帐号已冻结#define ERROR_CMD_TOO_LONG        0x0205      //认证命令字超过长度#define ERROR_CMD_NOT_TAIL        0x0206      //命令字没有结束符#define ERROR_CMD_NAME_NULL       0x0207      //用户名为空#define ERROR_OPTION_NOT_FOUND    0x0208      //不能识别的请求////////////////////////////////////////////////////////////////////////////////#define CMD_OK                    "OK"#define CMD_ERROR                 "ERROR"/*************************** End Auth cmd define ******************************/#define STREQ(x,y,z)    !strncmp(x,y,z)#define STRCEQ(x,y)     !strcmp(x,y)typedef int                AuthCode;typedef signed char        AuthBool;typedef unsigned char      BINT1;typedef unsigned short     BINT2;typedef unsigned long      BINT4;typedef unsigned long long BINT8;typedef struct _auth_user_info_ AuthUser;struct _auth_user_info_{    AuthUser *next;    AuthUser *prev;    char UserName[MAX_NAME_LEN];    char PassWord[MAX_PASSWD_LEN];    };typedef struct _online_user_info_ OnUser;struct _online_user_info_{    OnUser *next;    OnUser *prev;    BINT4  on_time;    BINT4  off_time;        char   UserName[MAX_NAME_LEN];    };struct _s5_auth_conf_{    //DB configure    char  db_host[20];    char  db_user[32];    char  db_passwd[32];    char  db_name[32];    BINT2 db_port;    //User auth mode    BINT1 auth_mode;    //1--hash mode, 2--databases mode;    BINT1 reserved1;    char  auth_addr[16];    BINT2 auth_port;    BINT2 reserved2;        char  conf_file[128];    char  log_file[128];    };struct _s5_auth_conf_ S5AuthConf;MYSQL db_conn;int S5AuthSocket;struct sockaddr_in S5AuthSsin;AuthUser *authUserTbl[MAX_USER_TBL];//pthread_t auth_serv_thread_id = 0;#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -