diff options
author | dequis <dx@dxzone.com.ar> | 2017-07-07 05:49:57 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2017-07-07 06:22:20 -0300 |
commit | 8bbf163cfb796524754d7872e148c9793cd4452f (patch) | |
tree | 7d1d8dbd182295564896de80c6d4edca66e6043b /facebook | |
parent | 5352f5822f0d12655b1120f76ec712713aa02079 (diff) | |
download | bitlbee-facebook-8bbf163cfb796524754d7872e148c9793cd4452f.tar.gz bitlbee-facebook-8bbf163cfb796524754d7872e148c9793cd4452f.tar.bz2 bitlbee-facebook-8bbf163cfb796524754d7872e148c9793cd4452f.tar.xz |
Add tweak values 1-15, sets orca version in the user agent
Since there are some issues I can't reproduce, let's do this experiment
properly and figure out if this really matters.
Value 1 is slightly newer. Value 2 is newer with the current set of
fields. Value 3 is what purple-facebook uses.
Adding 4 makes it http only, adding 8 makes it mqtt only. Some values
are redundant.
I suggest trying 1, 2, 3, 7 and 11.
Diffstat (limited to 'facebook')
-rw-r--r-- | facebook/facebook-api.c | 26 | ||||
-rw-r--r-- | facebook/facebook-api.h | 3 | ||||
-rw-r--r-- | facebook/facebook-http.c | 14 | ||||
-rw-r--r-- | facebook/facebook-http.h | 8 |
4 files changed, 49 insertions, 2 deletions
diff --git a/facebook/facebook-api.c b/facebook/facebook-api.c index 0ff315f..a72f386 100644 --- a/facebook/facebook-api.c +++ b/facebook/facebook-api.c @@ -89,6 +89,27 @@ fb_api_contacts_delta(FbApi *api, const gchar *delta_cursor); G_DEFINE_TYPE(FbApi, fb_api, G_TYPE_OBJECT); +static const gchar *agents[] = { + FB_API_AGENT, + FB_API_AGENT_BASE " " "[FBAN/Orca-Android;FBAV/64.0.0.5.83;FBPN/com.facebook.orca;FBLC/en_US;FBBV/26040814]", + FB_API_AGENT_BASE " " "[FBAN/Orca-Android;FBAV/109.0.0.17.70;FBBV/52182662]", + FB_API_AGENT_BASE " " "[FBAN/Orca-Android;FBAV/109.0.0.17.70;FBPN/com.facebook.orca;FBLC/en_US;FBBV/52182662]", + NULL, +}; + +static const gchar * +fb_api_get_agent_string(int tweak, gboolean mqtt) +{ + gboolean http_only = tweak & 4; + gboolean mqtt_only = tweak & 8; + + if (tweak <= 0 || tweak > 15 || (http_only && mqtt) || (mqtt_only && !mqtt)) { + return agents[0]; + } + + return agents[tweak & 3]; +} + static void fb_api_set_property(GObject *obj, guint prop, const GValue *val, GParamSpec *pspec) @@ -120,6 +141,7 @@ fb_api_set_property(GObject *obj, guint prop, const GValue *val, break; case PROP_TWEAK: priv->tweak = g_value_get_int(val); + fb_http_set_agent(priv->http, fb_api_get_agent_string(priv->tweak, 0)); break; default: @@ -896,7 +918,9 @@ fb_api_cb_mqtt_open(FbMqtt *mqtt, gpointer data) /* Write the information string */ fb_thrift_write_field(thft, FB_THRIFT_TYPE_STRING, 2, 1); - fb_thrift_write_str(thft, FB_API_MQTT_AGENT); + fb_thrift_write_str(thft, (priv->tweak != 0) + ? fb_api_get_agent_string(priv->tweak, 1) + : FB_API_MQTT_AGENT); /* Write the UNKNOWN ("cp"?) */ fb_thrift_write_field(thft, FB_THRIFT_TYPE_I64, 3, 2); diff --git a/facebook/facebook-api.h b/facebook/facebook-api.h index 7236b48..3ed0e41 100644 --- a/facebook/facebook-api.h +++ b/facebook/facebook-api.h @@ -110,7 +110,8 @@ * * The HTTP User-Agent header. */ -#define FB_API_AGENT "Facebook plugin / BitlBee / " PACKAGE_VERSION " " FB_ORCA_AGENT +#define FB_API_AGENT_BASE "Facebook plugin / BitlBee / " PACKAGE_VERSION +#define FB_API_AGENT FB_API_AGENT_BASE " " FB_ORCA_AGENT /** * FB_API_MQTT_AGENT diff --git a/facebook/facebook-http.c b/facebook/facebook-http.c index 6234d55..7335848 100644 --- a/facebook/facebook-http.c +++ b/facebook/facebook-http.c @@ -242,6 +242,20 @@ fb_http_cookies_parse_request(FbHttp *http, FbHttpRequest *req) g_strfreev(hdrs); } +void +fb_http_set_agent(FbHttp *http, const gchar *agent) +{ + FbHttpPrivate *priv; + + g_return_if_fail(FB_IS_HTTP(http)); + priv = http->priv; + + if (agent != priv->agent && g_strcmp0(agent, priv->agent)) { + g_free(priv->agent); + priv->agent = g_strdup(agent); + } +} + FbHttpRequest * fb_http_request_new(FbHttp *http, const gchar *url, gboolean post, FbHttpFunc func, gpointer data) diff --git a/facebook/facebook-http.h b/facebook/facebook-http.h index b3ff001..f7d02d9 100644 --- a/facebook/facebook-http.h +++ b/facebook/facebook-http.h @@ -206,6 +206,14 @@ void fb_http_cookies_parse_request(FbHttp *http, FbHttpRequest *req); /** + * fb_http_set_agent: + * @http: The #FbHttp. + * @agent: The new user agent string. + */ +void +fb_http_set_agent(FbHttp *http, const gchar *agent); + +/** * fb_http_request_new: * @http: The #FbHttp. * @url: The url. |