diff --git a/build.properties b/build.properties index c29e5da88..8c68b14b3 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -oc.version=1.8.7-snapshot +oc.version=1.8.8-snapshot ae2.version=rv2-stable-10 bc.version=7.1.24 diff --git a/changelog.md b/changelog.md index 841864bda..c82f9e553 100644 --- a/changelog.md +++ b/changelog.md @@ -1,17 +1,7 @@ ## Fixes/improvements -* [#3703] Fix potential packet memory leak. -* [#3729] Fix potential crash when opening the manual. -* Added a configuration option for network packet TTL. (Timothé GRISOT) -* Improved mod load times on certain platforms. (charagarland) -* Updated Chinese translation. (HfSr) -* Updated Unifont to 16.0.02. - -## OpenOS fixes/improvements - -* [#3714] Fix an OpenOS 1.8.0 regression causing event.pullFiltered() to effectively ignore filter timeouts. -* [#3727] Fix an exception handler bug in process.lua, uncovered by fixing recursive xpcall() handling in 1.8.4. +* [#3769] Add default user agent configuration option; change OpenComputers' default user agent to "opencomputers/$version". ## List of contributors -asie, charagarland, DragDen, HfSr, Timothé GRISOT +asie diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index ef798c1fb..b6f5d5512 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -1001,6 +1001,11 @@ opencomputers { "allow default" ] + # The default user agent used by HTTP calls made by the internet card. + # The string "$version" will be replaced with the version of the copy of + # OpenComputers used. + httpUserAgent: "opencomputers/$version" + # The time in seconds to wait for a response to a request before timing # out and returning an error message. If this is zero (the default) the # request will never time out. diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index ebb0c9d33..00071da39 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -500,6 +500,9 @@ class Settings(val config: Config) { def internetAccessAllowed(): Boolean = { internetAccessConfigured() && !internetFilteringRulesInvalid() } + + // >= 1.8.8 + val httpUserAgent = config.getString("internet.httpUserAgent") } object Settings { diff --git a/src/main/scala/li/cil/oc/server/component/InternetCard.scala b/src/main/scala/li/cil/oc/server/component/InternetCard.scala index 159ddf192..a13c8912d 100644 --- a/src/main/scala/li/cil/oc/server/component/InternetCard.scala +++ b/src/main/scala/li/cil/oc/server/component/InternetCard.scala @@ -515,6 +515,7 @@ object InternetCard { http.setDoInput(true) http.setDoOutput(post.isDefined) http.setRequestMethod(if (method.isDefined) method.get else if (post.isDefined) "POST" else "GET") + http.setRequestProperty("User-Agent", Settings.get.httpUserAgent.replace("$version", OpenComputers.Version)) headers.foreach(Function.tupled(http.setRequestProperty)) if (post.isDefined) { http.setReadTimeout(Settings.get.httpTimeout)