diff --git a/changelog.md b/changelog.md index 7ecb97c8bb..039adb659a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,43 +1,9 @@ ## New Features/Support -* Added: Experimental Lua 5.4 support (Lua 5.4.4). - * For now, this is hidden behind a configuration option. -* Added: Forestry circuit boards' internal layout is now available to Lua scripts. -* Added: Major upgrade of Lua libraries. - * Updated LuaJ to 3.0.2 with many third-party patches applied. - * JNLua is now compiled with proper optimizations - ~2x better performance! - * Lua 5.2 has been updated with gamax92's backported bugfixes. - * Lua 5.3 has been updated from 5.3.2 to 5.3.6. - * 64-bit integers in calls should now be handled properly. -* Added: New robot names. -* Added: Official support for AArch64 on Linux and macOS. -* Added: Source tank parameter for Transposer transferFluid(). (repo-alt) -* Added: Subtle indentations to Redstone I/O texture. - * The amount of darkened dots on each side marks the ordinal number of the side it responds to. -* Added: Support for non-BMP Unicode codepoints! - * To clarify, Unicode characters >= 0x10000 should now be fully supported - as long as they're provided in the font. -* Added: Support for partial font overrides in resource packs. - * If a resource pack's font.hex file only contains some glyphs, missing glyphs present in parent resource packs won't disappear. -* Added: Support for the "PATCH" HTTP method. (hohserg1) -* Added: New config option: "transposerFluidTransferRate". (repo-alt) -* Changed: New limitFlightHeight configuration definition. - * This allows values above 256 to be used, which may be useful for Cubic Chunks users. -* Changed: Replaced the forceNativeLibWithName config option with two new ones: forceNativeLibPlatform and forceNativeLibPathFirst. (TheCodex6824) - * forceNativeLibPlatform allows overriding the normally auto-detected platform string to a custom value, in case the user is on an unsupported platform. - * forceNativeLibPathFirst allows choosing a directory to check for natives in, instead of always searching in the jar for one. This allows custom natives to be used without packing them into the mod jar first, which should be much easier for end users. -* Changed: The game now crashes instead of reloading defaults if a config file is present but invalid. -* Fixed: [#3588] Renaming over other files does not properly free space. -* Fixed: [#3591] Memory leak with wrapped worlds from other mods. -* Fixed: [#3596] Freeze when connecting a ComputerCraft peripheral via an Adapter (Kosmos-Prime) -* Fixed: [#3603] computer.getDeviceInfo doesn't pause the computer immediately (AR2000AR) -* Fixed: [#3609] Swapped arguments in a graphics card "bitblt()" edge case. (Kosmos-Prime) -* Removed: Native Lua library support for x86 (32-bit) macOS. -* (1.7.10) Fixed: [#3239] Inconsistencies in Robot block clicking. - ## OpenOS fixes/improvements -* Fixed: [#3558] Invalid file modification timestamps in /bin/ls. +* Fixed OpenOS version number. ## List of contributors -AR2000AR, asie, hohserg1, Kosmos-Prime, payonel, repo-alt, Smok1e, TheCodex6824 +asie diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 8774fe3208..52481c524a 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -961,14 +961,6 @@ opencomputers { # Whether to allow adding custom headers to HTTP requests. enableHttpHeaders: true - # This is a list of allowed HTTP methods. If empty, any HTTP method - # can be used. - enableHttpMethods: [] - - # This is a number describing how many HTTP redirects are allowed - # while processing an HTTP request call. If 0, no redirects are allowed. - enableHttpRedirects: 50 - # Whether to allow TCP connections via internet cards. When enabled, # the `connect` method on internet card components becomes available. enableTcp: true diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua index b8628597f3..c3227931d8 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua @@ -1,7 +1,7 @@ -- called from /init.lua local raw_loadfile = ... -_G._OSVERSION = "OpenOS 1.8.0-snapshot" +_G._OSVERSION = "OpenOS 1.8.1" -- luacheck: globals component computer unicode _OSVERSION local component = component diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index 131ad54114..89b84b4d86 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -302,8 +302,6 @@ class Settings(val config: Config) { // internet val httpEnabled = config.getBoolean("internet.enableHttp") val httpHeadersEnabled = config.getBoolean("internet.enableHttpHeaders") - val httpMethodsEnabled = config.getStringList("internet.enableHttpMethods") - val httpRedirectsEnabled = config.getInt("internet.enableHttpRedirects") max -1 val tcpEnabled = config.getBoolean("internet.enableTcp") val httpHostBlacklist = Array(config.getStringList("internet.blacklist").map(new Settings.AddressValidator(_)): _*) val httpHostWhitelist = Array(config.getStringList("internet.whitelist").map(new Settings.AddressValidator(_)): _*) 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 67416b8f56..110f5af519 100644 --- a/src/main/scala/li/cil/oc/server/component/InternetCard.scala +++ b/src/main/scala/li/cil/oc/server/component/InternetCard.scala @@ -11,7 +11,7 @@ import java.nio.channels.SelectionKey import java.nio.channels.Selector import java.nio.channels.SocketChannel import java.util -import java.util.{Locale, UUID} +import java.util.UUID import java.util.concurrent._ import li.cil.oc.Constants import li.cil.oc.OpenComputers @@ -32,11 +32,6 @@ import li.cil.oc.api.prefab.AbstractValue import li.cil.oc.util.ThreadPoolFactory import net.minecraft.server.MinecraftServer import net.minecraftforge.fml.common.FMLCommonHandler -import org.apache.http.HttpHost -import org.apache.http.client.config.RequestConfig -import org.apache.http.client.methods.RequestBuilder -import org.apache.http.entity.StringEntity -import org.apache.http.impl.client.HttpClients import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsScala._ @@ -478,50 +473,34 @@ object InternetCard { private class RequestSender(val url: URL, val post: Option[String], val headers: Map[String, String], val method: Option[String]) extends Callable[InputStream] { override def call() = try { checkLists(InetAddress.getByName(url.getHost), url.getHost) - val proxy = FMLCommonHandler.instance.getMinecraftServerInstance.getServerProxy - - val methodStr = if (method.isDefined) method.get.toUpperCase(Locale.ROOT) else if (post.isDefined) "POST" else "GET" - if (Settings.get.httpMethodsEnabled.nonEmpty && !Settings.get.httpMethodsEnabled.contains(methodStr)) { - throw new IOException("method not allowed: " + methodStr) - } - - val requestBuilder = RequestBuilder.create(methodStr) - headers.foreach(Function.tupled(requestBuilder.addHeader)) - requestBuilder.setUri(url.toURI) - - val httpRequestConfig = RequestConfig.custom() - .setConnectTimeout(Settings.get.httpTimeout) - .setConnectionRequestTimeout(Settings.get.httpTimeout) - .setSocketTimeout(Settings.get.httpTimeout) - - val maxRedirects = Settings.get.httpRedirectsEnabled - if (maxRedirects > 0) { - httpRequestConfig.setMaxRedirects(maxRedirects) - } else if (maxRedirects == 0) { - httpRequestConfig - .setRedirectsEnabled(false) - .setRelativeRedirectsAllowed(false) - } - - if (proxy != null && proxy != Proxy.NO_PROXY) proxy.address() match { - case inetProxyAddress: InetSocketAddress => httpRequestConfig.setProxy(new HttpHost(inetProxyAddress.getAddress, inetProxyAddress.getPort)) - } - - val clientBuilder = HttpClients.custom() - clientBuilder.setDefaultRequestConfig(httpRequestConfig.build()) - - if (post.isDefined) { - requestBuilder.setEntity(new StringEntity(post.get)) - } - - val r = clientBuilder.build().execute(requestBuilder.build()) + val proxy = Option(FMLCommonHandler.instance.getMinecraftServerInstance.getServerProxy).getOrElse(java.net.Proxy.NO_PROXY) + url.openConnection(proxy) match { + case http: HttpURLConnection => try { + http.setDoInput(true) + http.setDoOutput(post.isDefined) + http.setRequestMethod(if (method.isDefined) method.get else if (post.isDefined) "POST" else "GET") + headers.foreach(Function.tupled(http.setRequestProperty)) + if (post.isDefined) { + http.setReadTimeout(Settings.get.httpTimeout) + + val out = new BufferedWriter(new OutputStreamWriter(http.getOutputStream)) + out.write(post.get) + out.close() + } - val input = r.getEntity.getContent - HTTPRequest.this.synchronized { - import collection.JavaConverters._ - response = Some((r.getStatusLine.getStatusCode, r.getStatusLine.getReasonPhrase, r.getAllHeaders.groupBy(h => h.getName).map(i => i._1 -> i._2.toList.asJava).asJava)) + val input = http.getInputStream + HTTPRequest.this.synchronized { + response = Some((http.getResponseCode, http.getResponseMessage, http.getHeaderFields)) + } + input + } + catch { + case t: Throwable => + http.disconnect() + throw t + } + case other => throw new IOException("unexpected connection type") } - input } catch { case e: UnknownHostException =>