Freeciv21
Develop your civilization from humble roots to a global empire
auth.cpp File Reference
#include "fcintl.h"
#include "log.h"
#include "shared.h"
#include "support.h"
#include "connection.h"
#include "packets.h"
#include "luascript_types.h"
#include "connecthand.h"
#include "notify.h"
#include "srv_main.h"
#include "script_fcdb.h"
#include "auth.h"
+ Include dependency graph for auth.cpp:

Go to the source code of this file.

Macros

#define GUEST_NAME   "guest"
 
#define MIN_PASSWORD_LEN   6
 
#define MAX_AUTH_TRIES   3
 
#define MAX_WAIT_TIME   300
 

Functions

static bool is_guest_name (const char *name)
 See if the name qualifies as a guest login name. More...
 
static void get_unique_guest_name (char *name)
 Return a unique guest name WARNING: do not pass pconn->username to this function: it won't return! More...
 
static bool is_good_password (const char *password, char *msg)
 Verifies that a password is valid. More...
 
bool auth_user (struct connection *pconn, char *username)
 Handle authentication of a user; called by handle_login_request() if authentication is enabled. More...
 
bool auth_handle_reply (struct connection *pconn, char *password)
 Receives a password from a client and verifies it. More...
 
void auth_process_status (struct connection *pconn)
 Checks on where in the authentication process we are. More...
 
const char * auth_get_username (struct connection *pconn)
 Get username for connection. More...
 
const char * auth_get_ipaddr (struct connection *pconn)
 Get connection ip address. More...
 

Variables

static const int auth_fail_wait [] = {1, 1, 2, 3}
 

Macro Definition Documentation

◆ GUEST_NAME

#define GUEST_NAME   "guest"

Definition at line 35 of file auth.cpp.

◆ MAX_AUTH_TRIES

#define MAX_AUTH_TRIES   3

Definition at line 38 of file auth.cpp.

◆ MAX_WAIT_TIME

#define MAX_WAIT_TIME   300

Definition at line 39 of file auth.cpp.

◆ MIN_PASSWORD_LEN

#define MIN_PASSWORD_LEN   6

Definition at line 37 of file auth.cpp.

Function Documentation

◆ auth_get_ipaddr()

const char* auth_get_ipaddr ( struct connection pconn)

Get connection ip address.

Definition at line 328 of file auth.cpp.

Referenced by script_fcdb_register_functions().

◆ auth_get_username()

const char* auth_get_username ( struct connection pconn)

Get username for connection.

Definition at line 317 of file auth.cpp.

Referenced by script_fcdb_register_functions().

◆ auth_handle_reply()

bool auth_handle_reply ( struct connection pconn,
char *  password 
)

Receives a password from a client and verifies it.

Definition at line 147 of file auth.cpp.

Referenced by server_packet_input().

◆ auth_process_status()

void auth_process_status ( struct connection pconn)

Checks on where in the authentication process we are.

Definition at line 197 of file auth.cpp.

Referenced by freeciv::server::pulse().

◆ auth_user()

bool auth_user ( struct connection pconn,
char *  username 
)

Handle authentication of a user; called by handle_login_request() if authentication is enabled.

If the connection is rejected right away, return FALSE, otherwise this function will return TRUE.

Definition at line 56 of file auth.cpp.

Referenced by handle_login_request().

◆ get_unique_guest_name()

static void get_unique_guest_name ( char *  name)
static

Return a unique guest name WARNING: do not pass pconn->username to this function: it won't return!

Definition at line 256 of file auth.cpp.

Referenced by auth_user().

◆ is_good_password()

static bool is_good_password ( const char *  password,
char *  msg 
)
static

Verifies that a password is valid.

Does some [very] rudimentary safety checks. TODO: do we want to frown on non-printing characters? Fill the msg (length MAX_LEN_MSG) with any worthwhile information that the client ought to know.

Definition at line 291 of file auth.cpp.

Referenced by auth_handle_reply().

◆ is_guest_name()

static bool is_guest_name ( const char *  name)
static

See if the name qualifies as a guest login name.

Definition at line 247 of file auth.cpp.

Referenced by auth_user(), and get_unique_guest_name().

Variable Documentation

◆ auth_fail_wait

const int auth_fail_wait[] = {1, 1, 2, 3}
static

Definition at line 43 of file auth.cpp.

Referenced by auth_handle_reply().