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

go-stun can't support coturn-4.5.0.6 #26

Closed
lxlenovostar opened this issue Nov 16, 2017 · 3 comments
Closed

go-stun can't support coturn-4.5.0.6 #26

lxlenovostar opened this issue Nov 16, 2017 · 3 comments

Comments

@lxlenovostar
Copy link

go-stun send binding request to coturn-4.5.0.6 will fail.

The binding request packet will drop for fingerprint. I have debug it in coturn.
packet check will fail in stun_is_command_message_full_check_str.

stun_is_command_message_full_check_str in src/client/ns_turn_msg.c
int stun_is_command_message_full_check_str(const u08bits* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present) {
    if(!stun_is_command_message_str(buf,blen))
        return 0;
    
    stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, blen, STUN_ATTRIBUTE_FINGERPRINT);
    if(!sar) {
        if(fingerprint_present)
            *fingerprint_present = 0; 
        if(stun_get_method_str(buf,blen) == STUN_METHOD_BINDING) {
            return 1;
        }    
        return !must_check_fingerprint;
    }    

    if(stun_attr_get_len(sar) != 4)
        return 0;

    const u32bits* fingerprint = (const u32bits*)stun_attr_get_value(sar);
    if(!fingerprint)
        return !must_check_fingerprint;
    
    u32bits crc32len = (u32bits)((((const u08bits*)fingerprint)-buf)-4);
    int ret = (*fingerprint == nswap32(ns_crc32(buf,crc32len) ^ ((u32bits)0x5354554e)));
    if(ret && fingerprint_present)
        *fingerprint_present = ret;
        
    return ret;
}   

I can use chrome send binding request to coturn-4.5.0.6 。So, this is bug in go-stun?
Thank you for reply.

@ccding
Copy link
Owner

ccding commented Nov 16, 2017

which line does it fail on?

@lxlenovostar
Copy link
Author

 u32bits crc32len = (u32bits)((((const u08bits*)fingerprint)-buf)-4);
    int ret = (*fingerprint == nswap32(ns_crc32(buf,crc32len) ^ ((u32bits)0x5354554e)));
    if(ret && fingerprint_present)
        *fingerprint_present = ret;

@ccding
Copy link
Owner

ccding commented Nov 17, 2017

I didn't mange to see any incompatibility in this code with the go-stun code. https://github.com/ccding/go-stun/blob/master/stun/attribute.go#L39

Can you do more test to see why the fingerprints can't be verified?

I would appreciate it if you could submit a pull request to fix this.

@ccding ccding closed this as completed in 784235e Jul 26, 2018
ccding pushed a commit that referenced this issue Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants