Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code to report to the caller of iksemel whether the jabber server mandates TLS connection #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/iksemel.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ int iks_start_sasl (iksparser *prs, enum ikssasltype type, char *username, char
#define IKS_STREAM_BIND 4
#define IKS_STREAM_SASL_PLAIN 8
#define IKS_STREAM_SASL_MD5 16
#define IKS_STREAM_STARTTLS_REQUIRED 32

typedef struct iksid_struct {
char *user;
Expand Down
25 changes: 21 additions & 4 deletions src/jabber.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,38 @@ iks_sasl_mechanisms (iks *x)
return sasl_mech;
}

static int
iks_starttls_options (iks *x)
{
int options = IKS_STREAM_STARTTLS;

while (x) {
if (!iks_strcmp(iks_name(x), "required")) {
options |= IKS_STREAM_STARTTLS_REQUIRED;
}

x = iks_next_tag(x);
}

return options;
}

int
iks_stream_features (iks *x)
{
int features = 0;

if (iks_strcmp(iks_name(x), "stream:features"))
return 0;
for (x = iks_child(x); x; x = iks_next_tag(x))
if (!iks_strcmp(iks_name(x), "starttls"))
features |= IKS_STREAM_STARTTLS;
else if (!iks_strcmp(iks_name(x), "bind"))
for (x = iks_child(x); x; x = iks_next_tag(x)) {
if (!iks_strcmp(iks_name(x), "starttls")) {
features |= iks_starttls_options(iks_child(x));
} else if (!iks_strcmp(iks_name(x), "bind"))
features |= IKS_STREAM_BIND;
else if (!iks_strcmp(iks_name(x), "session"))
features |= IKS_STREAM_SESSION;
else if (!iks_strcmp(iks_name(x), "mechanisms"))
features |= iks_sasl_mechanisms(iks_child(x));
}
return features;
}