Skip to content

Commit

Permalink
config_is_overtls
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Jun 29, 2023
1 parent 574e87f commit be803fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/ssr_executive.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct server_config * config_create(void) {
return config;
}

struct server_config * config_clone(struct server_config* src) {
struct server_config * config_clone(const struct server_config* src) {
struct server_config *config = NULL;
if (src == NULL) {
return config;
Expand Down Expand Up @@ -180,6 +180,25 @@ void config_ssrot_revision(struct server_config* config) {
}
}

bool config_is_overtls(const struct server_config* config) {
bool result = false;
struct server_config* cfg = config_clone(config);
config_ssrot_revision(cfg);

if (cfg->over_tls_enable) {
enum ssr_protocol proto = ssr_protocol_type_of_name(cfg->protocol);
enum ssr_obfs obfs = ssr_obfs_type_of_name(cfg->obfs);
enum ss_cipher_type method = ss_cipher_type_of_name(cfg->method);
// TODO: maybe the logic will change.
if (proto == ssr_protocol_origin && obfs == ssr_obfs_plain && method == ss_cipher_none) {
result = true;
}
}

config_release(cfg);
return result;
}

static int uid_cmp(const void *left, const void *right) {
char *l = *(char **)left;
char *r = *(char **)right;
Expand Down
3 changes: 2 additions & 1 deletion src/ssr_executive.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ void string_safe_assign(char **target, const char *value);
#endif

struct server_config * config_create(void);
struct server_config * config_clone(struct server_config* src);
struct server_config * config_clone(const struct server_config* src);
void config_release(struct server_config *cf);
void config_ssrot_revision(struct server_config* config);
bool config_is_overtls(const struct server_config* config);

void config_parse_protocol_param(struct server_config *config, const char *param);
void config_add_user_id_with_auth_key(struct server_config *config, const char *user_id, const char *auth_key);
Expand Down
1 change: 1 addition & 0 deletions win32/ssr-client/ssr-client-lib.def
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ config_create
config_clone
config_release
config_ssrot_revision
config_is_overtls

ss_cipher_name_of_type
ss_cipher_type_of_name
Expand Down

0 comments on commit be803fd

Please sign in to comment.