From 4cbe57d250041598b31f10ce0fa785168e6eb7a3 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Thu, 11 May 2023 15:28:39 +0200 Subject: [PATCH 1/3] start work on 1.8.1 --- changelog.md | 38 +------------------ .../loot/openos/lib/core/boot.lua | 2 +- 2 files changed, 3 insertions(+), 37 deletions(-) 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/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 From 555ae0e695db0ae252aa153a4a8f330568c41dab Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Tue, 30 May 2023 20:28:43 +0200 Subject: [PATCH 2/3] Revert "Migrate Internet Card to Apache HTTPClient, fix #3364" This reverts commit 9f1d521e4a6f4d75ce7460a7ef4ccd6bd29fbf45. --- src/main/resources/application.conf | 26 +++---- src/main/scala/li/cil/oc/Settings.scala | 2 - .../oc/server/component/InternetCard.scala | 76 +++++++------------ 3 files changed, 37 insertions(+), 67 deletions(-) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 76361606e5..4b447042be 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -959,19 +959,11 @@ 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 - # This is a list of forbidden domain names. If an HTTP request is made + # This is a list of blacklisted domain names. If an HTTP request is made # or a socket connection is opened the target address will be compared # to the addresses / address ranges in this list. It it is present in this # list, the request will be denied. @@ -993,9 +985,9 @@ opencomputers { "172.16.0.0/12" ] - # This is a list of allowed domain names. Requests may only be made + # This is a list of whitelisted domain names. Requests may only be made # to addresses that are present in this list. If this list is empty, - # requests may be made to all addresses not forbidden. Note that the + # requests may be made to all addresses not blacklisted. Note that the # blacklist is always applied, so if an entry is present in both the # whitelist and the blacklist, the blacklist will win. # Entries are of the same format as in the blacklist. Examples: @@ -1108,7 +1100,7 @@ opencomputers { # Radius in blocks of the disintegration behavior for each active input. disintegrationRange: 1 - # Allowed potions, i.e. potions that will be used for the potion + # Whitelisted potions, i.e. potions that will be used for the potion # behaviors nanomachines may trigger. This can contain strings or numbers. # In the case of strings, it has to be the internal name of the potion, # in case of a number it has to be the potion ID. Add any potion effects @@ -1320,7 +1312,7 @@ opencomputers { geolyzerNoise: 2 # By default the disassembler can only be used to disassemble items from - # OpenComputers itself (or objects allowed via the API). If you'd + # OpenComputers itself (or objects whitelisted via the API). If you'd # like to allow the disassembler to work on all kinds of items, even from # other mods, set this to true. disassembleAllTheThings: false @@ -1331,7 +1323,7 @@ opencomputers { # this chance of breaking in the process. disassemblerBreakChance: 0.05 - # Names of items / blocks that are forbidden. Recipes containing these + # Names of items / blocks that are blacklisted. Recipes containing these # as inputs will be ignored by the disassembler. disassemblerInputBlacklist: [ "minecraft:fire" @@ -1605,15 +1597,15 @@ opencomputers { # Chunkloader Upgrade settings. chunkloader { - # This is a list of forbidden dimensions in the form of numeric IDs. + # This is a list of blacklisted dimensions in the form of numeric IDs. # Chunkloaders may only be activated in dimensions that aren't present in # this list. dimBlacklist: [] - # This is a list of allowed dimensions in the form of numeric IDs. + # This is a list of whitelisted dimensions in the form of numeric IDs. # Chunkloaders may only be activated in dimensions that are present in # this list. If this list is empty, chunkloaders may be activated to all - # dimensions not forbidden. Note that the blacklist is always applied, + # dimensions not blacklisted. Note that the blacklist is always applied, # so if an entry is present in both the whitelist and the blacklist, the # blacklist will win. dimWhitelist: [] diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index 85eb7d4d78..c8cbac26dd 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -298,8 +298,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 0151294c75..3e8dd1fe42 100644 --- a/src/main/scala/li/cil/oc/server/component/InternetCard.scala +++ b/src/main/scala/li/cil/oc/server/component/InternetCard.scala @@ -11,8 +11,9 @@ 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 import li.cil.oc.Settings @@ -28,11 +29,6 @@ import li.cil.oc.api.prefab import li.cil.oc.api.prefab.AbstractValue import li.cil.oc.util.ThreadPoolFactory import net.minecraft.server.MinecraftServer -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._ @@ -474,50 +470,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 = MinecraftServer.getServer.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(MinecraftServer.getServer.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 => From 1c163dd7018376e270dc493f14c460070227cf16 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Tue, 30 May 2023 20:30:26 +0200 Subject: [PATCH 3/3] un-revert application.conf comment fixes --- src/main/resources/application.conf | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 4b447042be..15e178148b 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -963,7 +963,7 @@ opencomputers { # the `connect` method on internet card components becomes available. enableTcp: true - # This is a list of blacklisted domain names. If an HTTP request is made + # This is a list of forbidden domain names. If an HTTP request is made # or a socket connection is opened the target address will be compared # to the addresses / address ranges in this list. It it is present in this # list, the request will be denied. @@ -985,9 +985,9 @@ opencomputers { "172.16.0.0/12" ] - # This is a list of whitelisted domain names. Requests may only be made + # This is a list of allowed domain names. Requests may only be made # to addresses that are present in this list. If this list is empty, - # requests may be made to all addresses not blacklisted. Note that the + # requests may be made to all addresses not forbidden. Note that the # blacklist is always applied, so if an entry is present in both the # whitelist and the blacklist, the blacklist will win. # Entries are of the same format as in the blacklist. Examples: @@ -1100,7 +1100,7 @@ opencomputers { # Radius in blocks of the disintegration behavior for each active input. disintegrationRange: 1 - # Whitelisted potions, i.e. potions that will be used for the potion + # Allowed potions, i.e. potions that will be used for the potion # behaviors nanomachines may trigger. This can contain strings or numbers. # In the case of strings, it has to be the internal name of the potion, # in case of a number it has to be the potion ID. Add any potion effects @@ -1312,7 +1312,7 @@ opencomputers { geolyzerNoise: 2 # By default the disassembler can only be used to disassemble items from - # OpenComputers itself (or objects whitelisted via the API). If you'd + # OpenComputers itself (or objects allowed via the API). If you'd # like to allow the disassembler to work on all kinds of items, even from # other mods, set this to true. disassembleAllTheThings: false @@ -1323,7 +1323,7 @@ opencomputers { # this chance of breaking in the process. disassemblerBreakChance: 0.05 - # Names of items / blocks that are blacklisted. Recipes containing these + # Names of items / blocks that are forbidden. Recipes containing these # as inputs will be ignored by the disassembler. disassemblerInputBlacklist: [ "minecraft:fire" @@ -1597,15 +1597,15 @@ opencomputers { # Chunkloader Upgrade settings. chunkloader { - # This is a list of blacklisted dimensions in the form of numeric IDs. + # This is a list of forbidden dimensions in the form of numeric IDs. # Chunkloaders may only be activated in dimensions that aren't present in # this list. dimBlacklist: [] - # This is a list of whitelisted dimensions in the form of numeric IDs. + # This is a list of allowed dimensions in the form of numeric IDs. # Chunkloaders may only be activated in dimensions that are present in # this list. If this list is empty, chunkloaders may be activated to all - # dimensions not blacklisted. Note that the blacklist is always applied, + # dimensions not forbidden. Note that the blacklist is always applied, # so if an entry is present in both the whitelist and the blacklist, the # blacklist will win. dimWhitelist: []