📄 tsnew.h
字号:
/*
* Openmysee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <syslog.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include "ProtocolDefine.h"
#include "StructDefine.h"
#define MAX_BIND 10
#define AUTH_HEADER 12
#define NORMAL_HEADER 5
#define MAX_NET_NUM 5
#define MAX_CLIENT 3072
#define MAX_PEER 0x10 /* max peers returned by NEED_PEERS */
#define IPADDR_LEN 16 /*****IP地址最大长度*****/
#define MD5_LEN 32
#define SERVICE_LEN 128
#define TYPE_NP 0
#define TYPE_CP 1
#define MAX_CHANNEL 0x400 //1024
#define MAX_NP 0x40000 //262144
#define MAX_CP 0x10000 //65536
#define MAX_RM 0x4 //4
//#define TS4CP_PORT 22168
//#define TS4RM_PORT 22169
#define MAX_DATA 20000
#define MAX_LINE 1024
#define MAX_IDLE 120
#define SILENCE_TIME 2
#define MAX_INTERVAL 20
#define OBSERVE_LAYER 10
#define BASEDIR "/home/channel/"
#define MAX_LOG_COUNT 100 // call fflush() when current_log_count reaches MAX_LOG_COUNT
#include "StructDefine.h"
struct MyInterval
{
unsigned int start;
unsigned int len;
};
// Generic format of messages between TS and other peers
// Most often used in login process
struct MyMessage
{
unsigned int len;
unsigned char type;
char buffer[MAX_DATA];
};
// format of messages between TS and other peers
// with authcodes specified
struct MyTSMessage
{
unsigned int len;
unsigned char type;
unsigned int authcode1:24;
unsigned int authcode2;
char buffer[MAX_DATA];
} ;
struct MyChannelInfo
{
char md5[MD5_LEN+1];
unsigned char numinter;
struct MyInterval inter[MAX_INTERVAL];
};
struct MyChannel
{
char name[MD5_LEN+1];
unsigned int numclient;
unsigned int accumclient;
unsigned int latest_time;
#ifndef SORT_NET
struct MyEdge *PeerHead;
#else
unsigned int nclient_net[MAX_NET_NUM];
struct MyEdge *PeerHead[MAX_NET_NUM];
#endif
struct MySession *SCPhead;
struct MyChannel *next;
};
struct MyEdge
{
struct MyChannel *head;
struct MySession *me;
struct MyEdge *cnext;
struct MyEdge *enext;
unsigned char numinter;
unsigned int current;
struct MyInterval inter[MAX_INTERVAL];
};
struct MyNPInfo
{
struct CorePeerInfo p;
struct TransferInfo t;
struct StatInfo s;
int startBlock; // starting position of NP
int numchannel;
struct MyEdge *cur;
struct MyEdge *header;
};
struct MyCPInfo
{
char type;
unsigned char numHeads;
unsigned short connnum;
unsigned char maxConn;
char parameter[42];
int userid;
int resnum;
float band;
char servicetype[128];
};
struct MySession
{
int type;
int socket;
unsigned int host;
unsigned int intra;
unsigned short port;
unsigned short npport;
#ifdef SORT_NET
unsigned int net;
struct MySession *cachepeer[MAX_NET_NUM];
#else
struct MySession *cachepeer;
#endif
unsigned int auth;
unsigned int time_sec;
unsigned int last_access;
union
{
struct MyNPInfo p;
struct MyCPInfo cp;
} u;
struct MySession *hnext;
};
#define MAX_POLLUTE 1000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -