• 大小: 715KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签:

资源简介

sanguo是一个简单的网络游戏服务端框架。可以快速构建服务器集群内部以及服务器与客户端时间的通信。集群内部采用TCP通信。服务器客户端之间 支持TCP,websocket通信方式。

资源截图

代码片段和文件信息

// +build !windows

#include 
#include 
#include 
#include 

static int mgo_sasl_simple(void *context int id const char **result unsigned int *len)
{
if (!result) {
return SASL_BADPARAM;
}
switch (id) {
case SASL_CB_USER:
*result = (char *)context;
break;
case SASL_CB_AUTHNAME:
*result = (char *)context;
break;
case SASL_CB_LANGUAGE:
*result = NULL;
break;
default:
return SASL_BADPARAM;
}
if (len) {
*len = *result ? strlen(*result) : 0;
}
return SASL_OK;
}

typedef int (*callback)(void);

static int mgo_sasl_secret(sasl_conn_t *conn void *context int id sasl_secret_t **result)
{
if (!conn || !result || id != SASL_CB_PASS) {
return SASL_BADPARAM;
}
*result = (sasl_secret_t *)context;
return SASL_OK;
}

sasl_callback_t *mgo_sasl_callbacks(const char *username const char *password)
{
sasl_callback_t *cb = malloc(4 * sizeof(sasl_callback_t));
int n = 0;

size_t len = strlen(password);
sasl_secret_t *secret = (sasl_secret_t*)malloc(sizeof(sasl_secret_t) + len);
if (!secret) {
free(cb);
return NULL;
}
strcpy((char *)secret->data password);
secret->len = len;

cb[n].id = SASL_CB_PASS;
cb[n].proc = (callback)&mgo_sasl_secret;
cb[n].context = secret;
n++;

cb[n].id = SASL_CB_USER;
cb[n].proc = (callback)&mgo_sasl_simple;
cb[n].context = (char*)username;
n++;

cb[n].id = SASL_CB_AUTHNAME;
cb[n].proc = (callback)&mgo_sasl_simple;
cb[n].context = (char*)username;
n++;

cb[n].id = SASL_CB_LIST_END;
cb[n].proc = NULL;
cb[n].context = NULL;

return cb;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-06-26 02:13  sanguo-master\
     文件          86  2019-06-26 02:13  sanguo-master\.gitignore
     文件         406  2019-06-26 02:13  sanguo-master\Makefile
     文件        4681  2019-06-26 02:13  sanguo-master\README.md
     目录           0  2019-06-26 02:13  sanguo-master\center\
     文件        5664  2019-06-26 02:13  sanguo-master\center\center.go
     目录           0  2019-06-26 02:13  sanguo-master\center\protocol\
     文件       12760  2019-06-26 02:13  sanguo-master\center\protocol\center.pb.go
     文件         271  2019-06-26 02:13  sanguo-master\center\protocol\codec.go
     目录           0  2019-06-26 02:13  sanguo-master\center\protocol\proto\
     文件          44  2019-06-26 02:13  sanguo-master\center\protocol\proto\Makefile
     文件         664  2019-06-26 02:13  sanguo-master\center\protocol\proto\center.proto
     文件         366  2019-06-26 02:13  sanguo-master\center\protocol\register.go
     文件       42507  2019-06-26 02:13  sanguo-master\cluster.png
     目录           0  2019-06-26 02:13  sanguo-master\cluster\
     文件          31  2019-06-26 02:13  sanguo-master\cluster\Makefile
     目录           0  2019-06-26 02:13  sanguo-master\cluster\addr\
     文件        3292  2019-06-26 02:13  sanguo-master\cluster\addr\addr.go
     目录           0  2019-06-26 02:13  sanguo-master\cluster\addr\test\
     文件         615  2019-06-26 02:13  sanguo-master\cluster\addr\test\test.go
     文件        4128  2019-06-26 02:13  sanguo-master\cluster\center.go
     文件        4787  2019-06-26 02:13  sanguo-master\cluster\cluster.go
     文件        1565  2019-06-26 02:13  sanguo-master\cluster\dial.go
     文件        2878  2019-06-26 02:13  sanguo-master\cluster\dispatcher.go
     文件        3125  2019-06-26 02:13  sanguo-master\cluster\endpoint.go
     文件        5236  2019-06-26 02:13  sanguo-master\cluster\establish.go
     文件        2193  2019-06-26 02:13  sanguo-master\cluster\forginService.go
     文件        5284  2019-06-26 02:13  sanguo-master\cluster\harbor.go
     文件        7310  2019-06-26 02:13  sanguo-master\cluster\harbor.pb.go
     文件         341  2019-06-26 02:13  sanguo-master\cluster\harbor.proto
     文件        2883  2019-06-26 02:13  sanguo-master\cluster\heartbeat.pb.go
............此处省略448个文件信息

评论

共有 条评论