Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/slp.c @ 30459:a97d60c15e25
Support old-style Nonce, which should let us use direct connections to
aMSN (or msn-pecan?)
Refs #247.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 24 Apr 2010 06:41:52 +0000 |
parents | 4e532eedcab4 |
children | 0cc4f8651462 |
comparison
equal
deleted
inserted
replaced
30458:1664d74b2e69 | 30459:a97d60c15e25 |
---|---|
629 else if (!strcmp(type, "application/x-msnmsgr-transreqbody")) | 629 else if (!strcmp(type, "application/x-msnmsgr-transreqbody")) |
630 { | 630 { |
631 /* A direct connection negotiation request */ | 631 /* A direct connection negotiation request */ |
632 char *bridges; | 632 char *bridges; |
633 char *nonce; | 633 char *nonce; |
634 MsnDirectConnNonceType ntype; | |
634 | 635 |
635 purple_debug_info("msn", "got_invite: transreqbody received\n"); | 636 purple_debug_info("msn", "got_invite: transreqbody received\n"); |
636 | 637 |
637 /* Don't do anything if we already have a direct connection */ | 638 /* Don't do anything if we already have a direct connection */ |
638 if (slpcall->slplink->dc != NULL) | 639 if (slpcall->slplink->dc != NULL) |
639 return; | 640 return; |
640 | 641 |
641 bridges = get_token(content, "Bridges: ", "\r\n"); | 642 bridges = get_token(content, "Bridges: ", "\r\n"); |
642 nonce = get_token(content, "Hashed-Nonce: {", "}\r\n"); | 643 nonce = get_token(content, "Hashed-Nonce: {", "}\r\n"); |
644 if (nonce) { | |
645 ntype = DC_NONCE_SHA1; | |
646 } else { | |
647 nonce = get_token(content, "Nonce: {", "}\r\n"); | |
648 ntype = DC_NONCE_PLAIN; | |
649 } | |
643 if (nonce && bridges && strstr(bridges, "TCPv1") != NULL) { | 650 if (nonce && bridges && strstr(bridges, "TCPv1") != NULL) { |
644 /* | 651 /* |
645 * Ok, the client supports direct TCP connection | 652 * Ok, the client supports direct TCP connection |
646 * Try to create a listening port | 653 * Try to create a listening port |
647 */ | 654 */ |
648 MsnDirectConn *dc; | 655 MsnDirectConn *dc; |
649 | 656 |
650 dc = msn_dc_new(slpcall); | 657 dc = msn_dc_new(slpcall); |
658 dc->nonce_type = ntype; | |
651 strncpy(dc->remote_nonce, nonce, 36); | 659 strncpy(dc->remote_nonce, nonce, 36); |
652 dc->remote_nonce[36] = '\0'; | 660 dc->remote_nonce[36] = '\0'; |
653 | 661 |
654 dc->listen_data = purple_network_listen_range( | 662 dc->listen_data = purple_network_listen_range( |
655 0, 0, | 663 0, 0, |
661 if (dc->listen_data == NULL) { | 669 if (dc->listen_data == NULL) { |
662 /* Listen socket creation failed */ | 670 /* Listen socket creation failed */ |
663 | 671 |
664 purple_debug_info("msn", "got_invite: listening failed\n"); | 672 purple_debug_info("msn", "got_invite: listening failed\n"); |
665 | 673 |
666 msn_slp_send_ok(slpcall, branch, | 674 if (dc->nonce_type != DC_NONCE_PLAIN) |
667 "application/x-msnmsgr-transrespbody", | 675 msn_slp_send_ok(slpcall, branch, |
668 "Bridge: TCPv1\r\n" | 676 "application/x-msnmsgr-transrespbody", |
669 "Listening: false\r\n" | 677 "Bridge: TCPv1\r\n" |
670 "Hashed-Nonce: {00000000-0000-0000-0000-000000000000}\r\n" | 678 "Listening: false\r\n" |
671 "\r\n"); | 679 "Hashed-Nonce: {00000000-0000-0000-0000-000000000000}\r\n" |
680 "\r\n"); | |
681 else | |
682 msn_slp_send_ok(slpcall, branch, | |
683 "application/x-msnmsgr-transrespbody", | |
684 "Bridge: TCPv1\r\n" | |
685 "Listening: false\r\n" | |
686 "Nonce: {00000000-0000-0000-0000-000000000000}\r\n" | |
687 "\r\n"); | |
672 | 688 |
673 } else { | 689 } else { |
674 /* | 690 /* |
675 * Listen socket created successfully. | 691 * Listen socket created successfully. |
676 * Don't send anything here because we don't know the parameters | 692 * Don't send anything here because we don't know the parameters |
748 "Bridges: TCPv1\r\n" | 764 "Bridges: TCPv1\r\n" |
749 "NetID: %u\r\n" | 765 "NetID: %u\r\n" |
750 "Conn-Type: IP-Restrict-NAT\r\n" | 766 "Conn-Type: IP-Restrict-NAT\r\n" |
751 "UPnPNat: false\r\n" | 767 "UPnPNat: false\r\n" |
752 "ICF: false\r\n" | 768 "ICF: false\r\n" |
753 "Hashed-Nonce: {%s}\r\n" | 769 "%sNonce: {%s}\r\n" |
754 "\r\n", | 770 "\r\n", |
755 | 771 |
756 rand() % G_MAXUINT32, | 772 rand() % G_MAXUINT32, |
773 dc->nonce_type != DC_NONCE_PLAIN ? "Hashed-" : "", | |
757 dc->nonce_hash | 774 dc->nonce_hash |
758 ); | 775 ); |
759 | 776 |
760 } else { | 777 } else { |
761 /* Listen socket created successfully. */ | 778 /* Listen socket created successfully. */ |
766 "Bridges: TCPv1\r\n" | 783 "Bridges: TCPv1\r\n" |
767 "NetID: 0\r\n" | 784 "NetID: 0\r\n" |
768 "Conn-Type: Direct-Connect\r\n" | 785 "Conn-Type: Direct-Connect\r\n" |
769 "UPnPNat: false\r\n" | 786 "UPnPNat: false\r\n" |
770 "ICF: false\r\n" | 787 "ICF: false\r\n" |
771 "Hashed-Nonce: {%s}\r\n" | 788 "%sNonce: {%s}\r\n" |
772 "\r\n", | 789 "\r\n", |
773 | 790 |
791 dc->nonce_type != DC_NONCE_PLAIN ? "Hashed-" : "", | |
774 dc->nonce_hash | 792 dc->nonce_hash |
775 ); | 793 ); |
776 } | 794 } |
777 | 795 |
778 msg = msn_slpmsg_sip_new( | 796 msg = msn_slpmsg_sip_new( |