soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
6.83k stars 387 forks source link

Switch from http to https #482

Open pabs3 opened 1 year ago

pabs3 commented 1 year ago

Switch everything from http to https. Also fix a typo.

soimort commented 1 year ago

Have you tested if it actually works? gawk does not have built-in support for TLS. AFAIK simply changing port 80 to 443 in the TCP header will not work.

soimort commented 1 year ago

The https thing aside, the spelling fix looks very reasonable to me. Could you open a separate PR (only for the 2nd commit)?

pabs3 commented 1 year ago

I haven't tested it indeed.

I didn't consider that translate-shell itself would implement enough of HTTP in awk to be able to connect to these services, I thought that all the plugins would be calling curl as at least one of them does.

At some point not being able to use a modern HTTP implementation might become a liability, for example if some of the APIs started to require HTTPS or HTTP/2 or HTTP/3 then you would have to switch anyway.

Would you be open to switching all the plugins to use curl?

-- bye, pabs

https://bonedaddy.net/pabs3/

soimort commented 1 year ago

curl is used whenever gawk cannot handle a request (such as the HTTPS ones), but as it is an external process there is a performance overhead.

I think the best way to implement this is to have an option --secure to force the usage of curl (hence HTTPS) for all requests; defaults to plain HTTP/1.1 otherwise.

If Google Translate starts to require HTTPS one day in the future and gawk can't handle it, maybe it's then time to rewrite trans in a more modern language with a decent standard library. (Requiring HTTP/2 or HTTP/3 is a bit too radical at this point, though)

pabs3 commented 1 year ago

That sounds like a reasonable way to go, I'll try to take a look at implementing it over the weekend.

-- bye, pabs

https://bonedaddy.net/pabs3/

pabs3 commented 1 year ago

I've dropped the problematic parts of my patch, please merge the remaining changes and I will submit a new PR for the --secure feature, once I have time to work on it.

-- bye, pabs

https://bonedaddy.net/pabs3/