static int session = 1;
static int maxBandwidth;
-static int iCodecAlpha, iCodecBeta;
-static bool_t bPreferAlpha;
+int iCodecAlpha, iCodecBeta;
+bool_t bPreferAlpha;
extern int udpsock;
sendmsg = Msg_create(CodecVersion);
sendmsg->payload.codecVersion->alpha = version;
sendmsg->payload.codecVersion->beta = version;
- sendmsg->payload.codecVersion->beta = bPreferAlpha;
+ sendmsg->payload.codecVersion->prefer_alpha = bPreferAlpha;
Client_send_message_except(NULL, sendmsg);
-
+
+ Log_info("CELT codec switch 0x%x 0x%x (prefer 0x%x)", iCodecAlpha, iCodecBeta,
+ bPreferAlpha ? iCodecAlpha : iCodecBeta);
+
}
int Client_add(int fd, struct sockaddr_in *remote)
free(client->release);
if (client->os)
free(client->os);
+ if (client->playerName)
+ free(client->playerName);
free(client);
}
uint32_t rxcount, msgsize, drainleft, txcount, txsize;
int sessionId;
uint64_t key;
- char playerName[MAX_TEXT];
- int playerId;
+ char *playerName;
bool_t authenticated, deaf, mute;
char *os, *release;
uint32_t version;
#include "log.h"
#include "client.h"
#include "conf.h"
-
-#define UMURMUR_VERSION "0.1.3"
+#include "version.h"
void lockfile(const char *pidfile)
{
if (lfp < 0)
Log_fatal("Cannot open PID-file %s for writing", pidfile);
- sprintf(str,"%d\n",getpid());
+ sprintf(str,"%d\n", getpid());
write(lfp, str, strlen(str)); /* record pid to lockfile */
Log_info("PID-file: %s", pidfile);
}
void printhelp()
{
- printf("uMurmur version %s. Mumble protocol %d\n", UMURMUR_VERSION, MESSAGE_STREAM_VERSION);
+ printf("uMurmur version %s. Mumble protocol %d.%d.%d\n", UMURMUR_VERSION, PROTVER_MAJOR, PROTVER_MINOR, PROTVER_PATCH);
printf("Usage: umurmurd [-d] [-p <pidfile>] [-c <conf file>] [-h]\n");
printf(" -d - Do not deamonize\n");
printf(" -p <pidfile> - Write PID to this file\n");
#include "conf.h"
extern channel_t *defaultChan;
+extern int iCodecAlpha, iCodecBeta;
+extern bool_t bPreferAlpha;
static void sendServerReject(client_t *client, const char *reason, MumbleProto__Reject__RejectType type)
{
while (Client_iterate(&client_itr) != NULL) {
if (!IS_AUTH(client_itr))
continue;
- if (strncmp(client_itr->playerName, msg->payload.authenticate->username, MAX_TEXT) == 0) {
+ if (client_itr->playerName && strncmp(client_itr->playerName, msg->payload.authenticate->username, MAX_TEXT) == 0) {
char buf[64];
sprintf(buf, "Username already in use");
Log_debug("Username already in use");
}
/* Name & password */
- strncpy(client->playerName, msg->payload.authenticate->username, MAX_TEXT);
- client->playerId = client->sessionId;
-
+ client->playerName = strdup(msg->payload.authenticate->username);
/* Setup UDP encryption */
CryptState_init(&client->cryptState);
if (msg->payload.authenticate->n_celt_versions > MAX_CODECS)
Log_warn("Client has more than %d CELT codecs. Ignoring %d codecs",
MAX_CODECS, msg->payload.authenticate->n_celt_versions - MAX_CODECS);
+
+ Log_debug("Client %d has %d CELT codecs", client->sessionId, msg->payload.authenticate->n_celt_versions);
if (msg->payload.authenticate->n_celt_versions > 0) {
int i;
client->codec_count = msg->payload.authenticate->n_celt_versions > MAX_CODECS ?
MAX_CODECS : msg->payload.authenticate->n_celt_versions;
- for (i = 0; i < client->codec_count; i++)
+ for (i = 0; i < client->codec_count; i++) {
client->codecs[i] = msg->payload.authenticate->celt_versions[i];
+ Log_debug("Client %d CELT codec ver 0x%x", client->sessionId, client->codecs[i]);
+ }
} else {
client->codecs[0] = (int32_t)0x8000000a;
client->codec_count = 1;
}
+
recheckCodecVersions();
-
+
+ sendmsg = Msg_create(CodecVersion);
+ sendmsg->payload.codecVersion->alpha = iCodecAlpha;
+ sendmsg->payload.codecVersion->beta = iCodecBeta;
+ sendmsg->payload.codecVersion->prefer_alpha = bPreferAlpha;
+ Client_send_message(client, sendmsg);
+
/* Iterate channels and send channel info */
ch_itr = NULL;
Chan_iterate(&ch_itr);
sendmsg->payload.userState->has_session = true;
sendmsg->payload.userState->session = client->sessionId;
sendmsg->payload.userState->has_user_id = true;
- sendmsg->payload.userState->user_id = client->playerId;
+ sendmsg->payload.userState->user_id = client->sessionId;
sendmsg->payload.userState->name = strdup(client->playerName);
sendmsg->payload.userState->has_channel_id = true;
sendmsg->payload.userState->channel_id = ((channel_t *)client->channel)->id;
sendmsg->payload.serverSync->has_max_bandwidth = true;
sendmsg->payload.serverSync->max_bandwidth = getIntConf(MAX_BANDWIDTH);
sendmsg->payload.serverSync->has_allow_html = true;
- sendmsg->payload.serverSync->allow_html = false; /* Support this? */
+ sendmsg->payload.serverSync->allow_html = true; /* Support this? */
Client_send_message(client, sendmsg);
Log_info("User %s authenticated", client->playerName);
break;
case Ping:
- {
- uint64_t timestamp;
if (msg->payload.ping->has_good)
client->cryptState.uiRemoteGood = msg->payload.ping->good;
if (msg->payload.ping->has_late)
/* Ignoring the double values since they don't seem to be used */
sendmsg = Msg_create(Ping);
- timestamp = msg->payload.ping->timestamp;
- sendmsg->payload.ping->timestamp = timestamp;
-
+ sendmsg->payload.ping->timestamp = msg->payload.ping->timestamp;
+ sendmsg->payload.ping->has_timestamp = true;
sendmsg->payload.ping->good = client->cryptState.uiGood;
sendmsg->payload.ping->has_good = true;
sendmsg->payload.ping->late = client->cryptState.uiLate;
client->cryptState.uiLost, client->cryptState.uiResync);
break;
- }
case CryptSetup:
Log_debug("Voice channel crypt resync requested");
if (!msg->payload.cryptSetup->has_client_nonce) {
while (Client_iterate(&itr) != NULL) {
if (!IS_AUTH(itr))
continue;
- if (itr->playerId == msg->payload.textMessage->session[i]) {
+ if (itr->sessionId == msg->payload.textMessage->session[i]) {
if (!itr->deaf) {
Msg_inc_ref(msg);
Client_send_message(itr, msg);
+ Log_debug("Text message to session ID %d", itr->sessionId);
}
break;
}
Log_debug("Client OS %s", client->os);
}
break;
- case CodecVersion:
+ case PermissionQuery:
Msg_inc_ref(msg); /* Re-use message */
-
- /* XXX - fill in version */
+ msg->payload.permissionQuery->has_permissions = true;
+ msg->payload.permissionQuery->permissions = PERM_DEFAULT;
Client_send_message(client, msg);
break;
Msg_addPreamble(buffer, msg->messageType, len);
mumble_proto__codec_version__pack(msg->payload.codecVersion, bufptr);
break;
+ case PermissionQuery:
+ len = mumble_proto__permission_query__get_packed_size(msg->payload.permissionQuery);
+ if (len > MAX_MSGSIZE) {
+ Log_warn("Too big tx message. Discarding");
+ break;
+ }
+ Msg_addPreamble(buffer, msg->messageType, len);
+ mumble_proto__permission_query__pack(msg->payload.permissionQuery, bufptr);
+ break;
default:
Log_warn("Unsupported message %d", msg->messageType);
msg->payload.channelState = malloc(sizeof(MumbleProto__ChannelState));
mumble_proto__channel_state__init(msg->payload.channelState);
break;
+ case PermissionQuery:
+ msg->payload.permissionQuery = malloc(sizeof(MumbleProto__PermissionQuery));
+ mumble_proto__permission_query__init(msg->payload.permissionQuery);
+ break;
default:
Log_warn("Msg_create: Unsupported message %d", msg->messageType);
free(msg->payload.channelState);
}
break;
+ case PermissionQuery:
+ if (msg->unpacked)
+ mumble_proto__permission_query__free_unpacked(msg->payload.permissionQuery, NULL);
+ else {
+ free(msg->payload.permissionQuery);
+ }
+ break;
default:
Log_warn("Msg_free: Unsupported message %d", msg->messageType);
#include "list.h"
#include "types.h"
-#define MAX_TEXT 256
-#define MESSAGE_STREAM_VERSION 4
+#define PROTVER_MAJOR 1
+#define PROTVER_MINOR 2
+#define PROTVER_PATCH 0
+#define PROTOCOL_VERSION (((PROTVER_MAJOR << 16) | (PROTVER_MINOR << 8) | PROTVER_PATCH))
+
+#define MAX_TEXT 512
+
+
+#define PERM_NONE 0x0
+#define PERM_WRITE 0x1
+#define PERM_TRAVERSE 0x2
+#define PERM_ENTER 0x4
+#define PERM_SPEAK 0x8
+#define PERM_MUTEDEAFEN 0x10
+#define PERM_MOVE 0x20
+#define PERM_MAKECHANNEL 0x40
+#define PERM_LINKCHANNEL 0x80
+#define PERM_WHISPER 0x100
+#define PERM_TEXTMESSAGE 0x200
+#define PERM_MAKETEMPCHANNEL 0x400
+// Root channel only
+#define PERM_KICK 0x10000
+#define PERM_BAN 0x20000
+#define PERM_REGISTER 0x40000
+#define PERM_SELFREGISTER 0x80000
+#define PERM_CACHED 0x8000000
+#define PERM_ALL 0xf07ff
+
+#define PERM_DEFAULT (PERM_TRAVERSE | PERM_ENTER | PERM_SPEAK | PERM_WHISPER | PERM_TEXTMESSAGE)
typedef enum {
Version,
ChannelState,
UserRemove,
UserState,
- BanList,
+ BanList, /* 10 */
TextMessage,
PermissionDenied,
ACL,
ContextAction,
UserList,
VoiceTarget,
- PermissionQuery,
+ PermissionQuery, /* 20 */
CodecVersion,
} messageType_t;
} message_t;
-
int Msg_messageToNetwork(message_t *msg, uint8_t *buffer);
message_t *Msg_networkToMessage(uint8_t *data, int size);
void Msg_free(message_t *msg);
Timer_init(&janitorTimer);
+ Log_info("uMurmur voicechat server started -- http://code.google.com/p/umurmur/");
+
/* Main server loop */
while (!shutdown_server) {
struct sockaddr_in remote;
sk_SSL_CIPHER_push(cipherlist_new, cipher);
}
}
- Log_info("List of ciphers:");
+ Log_debug("List of ciphers:");
if (cipherlist_new) {
for ( i = 0; (cipher = sk_SSL_CIPHER_value(cipherlist_new, i)) != NULL; i++) {
- Log_info("%s", SSL_CIPHER_get_name(cipher));
+ Log_debug("%s", SSL_CIPHER_get_name(cipher));
offset += snprintf(cipherstring + offset, 1024 - offset, "%s:", SSL_CIPHER_get_name(cipher));
}
cipherstring[offset - 1] = '\0';
--- /dev/null
+#ifndef VERSION_H_989876
+#define VERSION_H_989876
+
+#define UMURMUR_VERSION "1.2.0-beta1"
+
+#endif
+