Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/si.c @ 29869:f44718de8b06
merged with im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 22 Feb 2010 16:05:25 +0900 |
parents | 4491a662d527 356d1f40a56d |
children | f988f25259c7 |
comparison
equal
deleted
inserted
replaced
29445:d74e3cd6cbb5 | 29869:f44718de8b06 |
---|---|
852 xmlnode_set_attrib(query, "sid", jsx->stream_id); | 852 xmlnode_set_attrib(query, "sid", jsx->stream_id); |
853 | 853 |
854 /* If we successfully started listening locally */ | 854 /* If we successfully started listening locally */ |
855 if (sock >= 0) { | 855 if (sock >= 0) { |
856 gchar *jid; | 856 gchar *jid; |
857 const char *local_ip, *public_ip; | 857 GList *local_ips = |
858 | 858 purple_network_get_all_local_system_ips(); |
859 const char *public_ip; | |
860 gboolean has_public_ip = FALSE; | |
861 | |
859 jsx->local_streamhost_fd = sock; | 862 jsx->local_streamhost_fd = sock; |
860 | 863 |
861 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, | 864 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, |
862 jsx->js->user->domain, jsx->js->user->resource); | 865 jsx->js->user->domain, jsx->js->user->resource); |
863 xfer->local_port = purple_network_get_port_from_fd(sock); | 866 xfer->local_port = purple_network_get_port_from_fd(sock); |
864 g_snprintf(port, sizeof(port), "%hu", xfer->local_port); | 867 g_snprintf(port, sizeof(port), "%hu", xfer->local_port); |
865 | 868 |
866 /* Include the localhost's IP (for in-network transfers) */ | 869 public_ip = purple_network_get_my_ip(jsx->js->fd); |
867 local_ip = purple_network_get_local_system_ip(jsx->js->fd); | 870 |
868 if (strcmp(local_ip, "0.0.0.0") != 0) { | 871 /* Include the localhost's IPs (for in-network transfers) */ |
872 while (local_ips) { | |
873 gchar *local_ip = local_ips->data; | |
869 streamhost_count++; | 874 streamhost_count++; |
870 streamhost = xmlnode_new_child(query, "streamhost"); | 875 streamhost = xmlnode_new_child(query, "streamhost"); |
871 xmlnode_set_attrib(streamhost, "jid", jid); | 876 xmlnode_set_attrib(streamhost, "jid", jid); |
872 xmlnode_set_attrib(streamhost, "host", local_ip); | 877 xmlnode_set_attrib(streamhost, "host", local_ip); |
873 xmlnode_set_attrib(streamhost, "port", port); | 878 xmlnode_set_attrib(streamhost, "port", port); |
879 if (purple_strequal(local_ip, public_ip)) | |
880 has_public_ip = TRUE; | |
881 g_free(local_ip); | |
882 local_ips = g_list_delete_link(local_ips, local_ips); | |
874 } | 883 } |
875 | 884 |
876 /* Include the public IP (assuming that there is a port mapped somehow) */ | 885 /* Include the public IP (assuming that there is a port mapped somehow) */ |
877 public_ip = purple_network_get_my_ip(jsx->js->fd); | 886 if (!has_public_ip && strcmp(public_ip, "0.0.0.0") != 0) { |
878 if (strcmp(public_ip, local_ip) != 0 && strcmp(public_ip, "0.0.0.0") != 0) { | |
879 streamhost_count++; | 887 streamhost_count++; |
880 streamhost = xmlnode_new_child(query, "streamhost"); | 888 streamhost = xmlnode_new_child(query, "streamhost"); |
881 xmlnode_set_attrib(streamhost, "jid", jid); | 889 xmlnode_set_attrib(streamhost, "jid", jid); |
882 xmlnode_set_attrib(streamhost, "host", public_ip); | 890 xmlnode_set_attrib(streamhost, "host", public_ip); |
883 xmlnode_set_attrib(streamhost, "port", port); | 891 xmlnode_set_attrib(streamhost, "port", port); |