Page 1 of 1

Lua Web Access

Posted: Fri May 10, 2019 15:46
by Wekabu city
So why does

Code: Select all

local loc = "http://geolykt.de/tt/files/update.txt"
local file = assert(io.open(loc,"r"))
Debug.toast(file.read())
not work?
Looking through the Game logs I get this:
...
end:19 io error: http:/geolykt.de/tt/files/update.txt: open failed: ENOENT (No such file or directory)

...
at org.luaj.vm2.LuaValue.error(Unknown Source)
at org.luaj.vm2.lib.BaseLib$_assert.invoke(Unknown Source)
at org.luaj.vm2.LuaClosure.execute(Unknown Source)
at org.luaj.vm2.LuaClosure.call(Unknown Source)
at info.flowersoft.theotown.theotown.scripting.MethodCluster.invoke(MethodCluster.java:30)
at info.flowersoft.theotown.theotown.scripting.ScriptingEnvironment.callMethodOnce(ScriptingEnvironment.java:190)
at info.flowersoft.theotown.theotown.stages.LoadingStage.prepare(LoadingStage.java:50049)
at io.blueflower.stapel2d.gamestack.GameStack.update(GameStack.java:111)
at info.flowersoft.theotown.theotown.Renderer.onDrawFrame(Renderer.java:49)
at info.flowersoft.theotown.theotown.MainActivity$2.onDrawFrame(MainActivity.java:173)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1553)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)

now you May think it's because io.open() is Not meant to be invoked with an url as a argument, but it actually seems Like it does:
with https enforce on the Webserver and Bad internet I get this
...
end:19 io error: http:/geolykt.de/tt/files/update.txt: open failed: ENOENT (No such file or directory)

...
at org.luaj.vm2.LuaValue.error(Unknown Source)
at org.luaj.vm2.lib.BaseLib$_assert.invoke(Unknown Source)
at org.luaj.vm2.LuaClosure.execute(Unknown Source)
at org.luaj.vm2.LuaClosure.call(Unknown Source)
at info.flowersoft.theotown.theotown.scripting.MethodCluster.invoke(MethodCluster.java:30)
at info.flowersoft.theotown.theotown.scripting.ScriptingEnvironment.callMethodOnce(ScriptingEnvironment.java:190)
at info.flowersoft.theotown.theotown.stages.LoadingStage.prepare(LoadingStage.java:50049)
at io.blueflower.stapel2d.gamestack.GameStack.update(GameStack.java:111)
at info.flowersoft.theotown.theotown.Renderer.onDrawFrame(Renderer.java:49)
at info.flowersoft.theotown.theotown.MainActivity$2.onDrawFrame(MainActivity.java:173)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1553)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)

2019/05/10 08:44:32: Time
javax.net.ssl.SSLProtocolException: Read error: ssl=0x8ce6a140: Failure in SSL library, usually a protocol error
error:100000d7:SSL routines:OPENSSL_internal:SSL_HANDSHAKE_FAILURE (external/boringssl/src/ssl/s3_pkt.c:402 0x9e037912:0x00000000)
javax.net.ssl.SSLProtocolException: Read error: ssl=0x8ce6a140: Failure in SSL library, usually a protocol error
error:100000d7:SSL routines:OPENSSL_internal:SSL_HANDSHAKE_FAILURE (external/boringssl/src/ssl/s3_pkt.c:402 0x9e037912:0x00000000)
at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:758)
at com.android.okhttp.okio.Okio$2.read(Okio.java:136)
at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
at com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)
at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:906)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:782)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:463)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java)
at java.net.URL.openStream(URL.java:1057)
at info.flowersoft.theotown.theotown.resources.InternetTime.readServerTime(InternetTime.java:98)
at info.flowersoft.theotown.theotown.resources.InternetTime$1.run(InternetTime.java:1019)

2019/05/10 08:45:27: Time
javax.net.ssl.SSLHandshakeException: Handshake failed
javax.net.ssl.SSLHandshakeException: Handshake failed
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:429)
at com.android.okhttp.Connection.connectTls(Connection.java:235)
at com.android.okhttp.Connection.connectSocket(Connection.java:199)
at com.android.okhttp.Connection.connect(Connection.java:172)
at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java)
at java.net.URL.openStream(URL.java:1057)
at info.flowersoft.theotown.theotown.resources.InternetTime.readServerTime(InternetTime.java:98)
at info.flowersoft.theotown.theotown.resources.InternetTime$1.run(InternetTime.java:1019)
Suppressed: javax.net.ssl.SSLHandshakeException: Handshake failed
... 16 more
Suppressed: javax.net.ssl.SSLHandshakeException: Connection closed by peer
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
... 15 more
Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x8ce6a640: Failure in SSL library, usually a protocol error
error:1000043e:SSL routines:OPENSSL_internal:TLSV1_ALERT_INAPPROPRIATE_FALLBACK (external/boringssl/src/ssl/s3_pkt.c:610 0x8ce179a0:0x00000001)
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
... 15 more
Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x9dfd9e40: Failure in SSL library, usually a protocol error
error:1000043e:SSL routines:OPENSSL_internal:TLSV1_ALERT_INAPPROPRIATE_FALLBACK (external/boringssl/src/ssl/s3_pkt.c:610 0x8ce15480:0x00000001)
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
... 15 more

This means that it's Not actually possible to Access Files on distant webservers, but also intedent to be done this way, so how do I use it correctly?

OK, maybe Lobby did never thought Somebody would do that ...

Re: Lua Web Access

Posted: Fri May 10, 2019 16:09
by JustAnyone
It is really powerful and could be used for harm.

Re: Lua Web Access

Posted: Fri May 10, 2019 16:14
by Wekabu city
That's a thing, but I think read-only access should be still possible. Maybe it can be used to dain your data capacity, but it seems like Theotown already monitors the time you stay on the internet (probably to keep Threads 'clean'.

Re: Lua Web Access

Posted: Fri May 10, 2019 16:27
by Lobby
1. Any GET request can be used to transfer data to a server.

2. From a user's point of view connecting to the internet isn't necessarily something you would expect from a plugin.

3. Local regulations would require us/you to include an appropriate data protection declaration for that data transmission, even if nothing is tracked or saved on the server side.

May I ask for what reason you want to connect to a server? The player may be offline and resource files should be bundled with the plugin.

Re: Lua Web Access

Posted: Fri May 10, 2019 16:40
by Wekabu city
Update checking for plugins.
But I don't want the put data to the webserver, rather retrive data from the webserver, if you misunderstood me.