Trying to port Rss-bridge for Sandstorm

19 views
Skip to first unread message

Benoit At INSA

unread,
Aug 15, 2017, 5:59:28 AM8/15/17
to sandst...@googlegroups.com
Hello there ! :D

I'm currently trying to package https://github.com/RSS-Bridge/rss-bridge
for Sandstorm, and it's my first time trying to port an app for it. I
followed the official doc and got it running on my dev station, except,
I can't find a complete explanation on how to allow it to connect to
external services.

The main job of this app is to connect to external platforms like
Amazon, Tumblr, Facebook, whatever ... that don't provide rss feeds, and
convert their data into rss, that can then be read by other applications.

All I need is some simple way to allow my app to make GET/POST requests
to any websites it wants, so as to fetch data. Then, I guess I will have
to export the HTTP API to allow other apps to fetch the produced rss
feeds, but that seems well-documented enough.

Actually, have you yet developped a simple way to keep a grain always
open (except the hacky method of keeping a web browser with an open tab
somewhere ?).

Can anyone here point me in the right direction please ?

Thank you very much ! ;-)

Xia0ben.

Benoit At INSA

unread,
Aug 15, 2017, 9:56:37 AM8/15/17
to sandst...@googlegroups.com
Hi again,

I tried to follow the Powerbox doc
(https://docs.sandstorm.io/en/latest/developing/powerbox/), and tried
quite a few things, but I am currently stuck by X-Sandstorm-Session-Id.
When I make my request to the server, the headers it receives are the
following :

All HTTP Headers :
------------------------------------------------------
Connection: close
Accept-Language: en-US,en;q=0.5
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0)
Gecko/20100101 Firefox/54.0
X-Sandstorm-Tab-Id: 2fbcc943382d3637f14b1017b48086f0
X-Sandstorm-Username: Bob%20Dev%20User
X-Sandstorm-User-Id: 6e8a1a4950cc4915cee15e476dbf28ba
X-Sandstorm-Preferred-Handle: bob
X-Sandstorm-User-Picture:
http://static.local.sandstorm.io:6080/identicon/6e8a1a4950cc4915cee15e476dbf28ba?s=256
X-Sandstorm-User-Pronouns: male
X-Sandstorm-Permissions:
X-Sandstorm-Base-Path:
http://0064dc58d81d66fded6cc3a2ed4a04af.local.sandstorm.io:6080
Host: 0064dc58d81d66fded6cc3a2ed4a04af.local.sandstorm.io:6080
X-Forwarded-Proto: http
X-Sandstorm-Session-Id: 0
Cookie: __cfduid=d12330cd7de52266f084df180513c7f551502789993
Accept: */*
Accept-Encoding: gzip, deflate

It seems like there is problem with X-Sandstorm-Session-Id : it
shouldn't be 0, should it ? When trying to get only the
'X-Sandstorm-Session-Id' header with "$session_id =
$_SERVER['X-Sandstorm-Session-Id'];", I get nothing.
------------------------------------------------------

So I tried anyway to make a request at the following URL with the
following content, cheating a little bit by adding the 0 by hand :
------------------------------------------------------
http://http-bridge/session/0/claim

{"requestToken":"TFlhB4uaQgu3HhzfwGmDnwXZJg1RsC9u9v2s_gudmlV","requiredPermissions":"[]"}

But all I get is :
------------------------------------------------------
Not Found

You can find the meager code I wrote here :
https://github.com/Xia0ben/rss-bridge/ (see last 2 commits).

What am I missing here ? O_o

Thank you in advance for any advice/insight as to what I should to fix
this ;-).

Xia0ben.
--
Benoit Renault,
Vice-Président du Clubelek,
L'association de mécatronique de l'INSA Lyon.

Site web : http://clubelek.fr/
Mail : club...@insa-lyon.fr
Facebook : https://facebook.com/Clubelek

Jacob Weisz

unread,
Aug 15, 2017, 10:06:01 AM8/15/17
to sandst...@googlegroups.com
There's a few directions I can point you in, and hopefully be of some
assistance.

Generally, Sandstorm apps are blocked from having arbitrary HTTP access
to external resources. Since a big point of Sandstorm is sandboxing apps
so they can't misbehave without permission, there is not really a
"simple way" to allow your app to make any GET/POST requests to any
websites it wants.

You can probably still use the way TinyTinyRSS does it for now, but that
method is likely to get replaced and eventually blocked off for newer
apps, as it is a hack. It has a method called HttpGet that uses a
intentional hole in Sandstorm to get arbitrary HTTP:
https://github.com/jparyani/Tiny-Tiny-RSS/blob/sandstorm/sandstorm/sandstorm-httpGet.c%2B%2B

The new method is to make a Powerbox request, where the user grants the
app permission to talk to external apps or services. I do not think
anyone is using this yet for arbitrary HTTP access, and I am not sure
whether or not you can yet. But the goal is that as part of say adding a
site that you want to access, you'd grant the app access to connect to
it with a permission the user would be able to revoke:
https://docs.sandstorm.io/en/latest/developing/powerbox/

One of the features of the Powerbox I do know IS being used by an app is
an IpNetwork capability, also mentioned on the page above, which simply
does grant your app arbitrary network access on all ports. The big
downside to this one, is that currently only the admin of a Sandstorm
server can grant that permission, so it can only be used on your own
Sandstorm server. The app using this method currently is:
https://github.com/zenhack/sandstorm-znc

There is a stayAwake method in the Sandstorm API for keeping your app
open, though if I recall, there is no way to make it automatically come
back after a restart of the Sandstorm server:
https://github.com/sandstorm-io/sandstorm/blob/master/src/sandstorm/grain.capnp#L101

--
Jacob Weisz
in...@jacobweisz.com
> --
> You received this message because you are subscribed to the Google Groups
> "Sandstorm Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sandstorm-de...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sandstorm-dev/c64343ef-bd0a-f4e3-7320-b5d9ad15ee2b%40insa-lyon.fr.
> For more options, visit https://groups.google.com/d/optout.

Benoit At INSA

unread,
Aug 15, 2017, 12:04:40 PM8/15/17
to sandst...@googlegroups.com

Hello Jacob !

Thank you very much for your input !

"

One of the features of the Powerbox I do know IS being used by an app is
an IpNetwork capability, also mentioned on the page above, which simply
does grant your app arbitrary network access on all ports. The big
downside to this one, is that currently only the admin of a Sandstorm
server can grant that permission, so it can only be used on your own
Sandstorm server. The app using this method currently is:
https://github.com/zenhack/sandstorm-znc
"
=> Actually, this looks very fine to me ! Though, as I haven't studied the Go language yet, I don't quite grasp the proportion of the adaptations you've had to make to make your application be compatible. Most of it seems like is done in ipnetwork_proxy.go and config.go, but I'm not sure. Actually as I'm no PHP specialist either, I don't see how I can translate this at all ^^. I couldn't find guidelines on how to implement it either in the docs, so I guess that won't be easy :/ .

Well I'll give this another shot when I have more time =) !

Xia0ben.
-- 
Benoit Renault,
Vice-Président du Clubelek,
L'association de mécatronique de l'INSA Lyon.

Site web : http://clubelek.fr/

Jacob Weisz

unread,
Aug 15, 2017, 12:07:12 PM8/15/17
to sandst...@googlegroups.com
Ian (zenhack) is the developer of the ZNC port for Sandstorm, and is actually one of the best people to talk to about any Powerbox/IpNetwork capability questions you might have because he's fiddled with those features a lot.

--
  Jacob Weisz

--
You received this message because you are subscribed to the Google Groups "Sandstorm Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sandstorm-de...@googlegroups.com.

Ian Denhardt

unread,
Aug 15, 2017, 2:33:24 PM8/15/17
to Benoit At INSA, sandst...@googlegroups.com
I'd recommend against using IpNetwork unless you need to speak some
protocol other than http; in the case of that app I needed to connect to
an IRC server, so there was no way around it. Ideally, it would just
request a TcpPort, not full IpNetwork, since that's all it needs. But I
don't know if sandstorm will actually directly answer requests for that
interface? At the time at least I was under the impression that it
wouldn't.

The Go example is also potentially less applicable, since I'm doing the
claimRequest via the native capnproto APIs, where as you're trying to
use sandstorm-http-bridge. The X-Sandstorm-Session-Id header definitely
*shouldn't* be 0; I'm not sure what could be going on there.

Quoting Benoit At INSA (2017-08-15 12:04:36)

> => Actually, this looks very fine to me ! Though, as I haven't studied
> the Go language yet, I don't quite grasp the proportion of the
> adaptations you've had to make to make your application be compatible.
> Most of it seems like is done in [2]ipnetwork_proxy.go and config.go,
signature.asc
Reply all
Reply to author
Forward
0 new messages