tgl icon indicating copy to clipboard operation
tgl copied to clipboard

Automatically detect DC id when the application doesn't know it

Open hedayat opened this issue 10 years ago • 3 comments

  • When the application wants to use its primary server address given by Telegram instead of hardcoded DC list, it can add this address with TGL_DC_AUTO_ID as its id number (and it should not supply any other DCs)
  • Fix DC id range check assert in some functions to use TGL_MAX_DC_NUM rather than MAX_DC_ID

hedayat avatar Jul 12 '15 22:07 hedayat

Sorry, removing trailing whitespace by my editor seems to make my pull request hard to read. If you think it is necessary, I'll try to re-generate new pull requests so that whitespace changes are either isolated in a separate PR, or removed completely. But I hope you can merge current PRs. I'll try to do this in future.

hedayat avatar Jul 12 '15 22:07 hedayat

@hedayat Don't understand. What will you gain from using AUTO_DC_ID?

Thx for your pull requests anyway. Please write me in telegram, because I don't open github too often. ( username in telegram is vysheng, easy to guess)

vysheng avatar Jul 30 '15 10:07 vysheng

With AUTO_DC_ID, instead of hardcoding some Telegram server IP addresses with known IDs into your application you can use the DC IP provided by Telegram when you register your application, and doesn't need to know its ID (since telegram doesn't provide it).

Actually I did it because I felt that this is what Telegram expects an application developer to do, and I was looking at your code to determine where should I put the provided IP address. It took me awhile to understand that I can't pass arbitrary ID number when calling bl_do_dc_option(). Without this patch, the application developer cannot use DC provided by Telegram with tgl, since he doesn't know the ID of that DC. He should find the IP address(es) and ID(s) of Telegram DCs from somewhere (e.g. telegram-cli source code) and use them in his application. I didn't look 'right' to me, so I added the possibility to use AUTO_DC_ID. It also looks that it is the behavior Telegram expects, since they don't provide such list of DC IP+IDs in their docs or their application registration form.

hedayat avatar Jul 31 '15 10:07 hedayat