Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC GUI #610

Closed
JustArchi opened this issue Aug 12, 2017 · 82 comments
Closed

IPC GUI #610

JustArchi opened this issue Aug 12, 2017 · 82 comments
Labels
✨ Enhancement Issues marked with this label indicate further enhancements to the program, such as new features. 🤝 Help welcome Issues marked with this label are open for help. If you could offer us a hand, please do! ⛔ On hold Issues marked with this label are blocked from being worked on, very often due to third-parties. 🙏 Wishlist Issues marked with this label are wishlisted. We'd like to make them happen but they're not crucial.

Comments

@JustArchi
Copy link
Member

JustArchi commented Aug 12, 2017

Since we have a nicely working HTTP IPC in ASF V3 now, we could make use of that fact and code a nice ASF GUI purely in html, javascript and css. IPC can easily communicate with ASF and execute commands, fetch status and expose other things over friendly HTTP interface, with all sort of needed events and stuff. Something like typical web-admin interface for a game server.

Of course, as usual I'm not interested in doing any of that myself, so I'm just putting up issue on hold in case anybody would want to make it happen. I'm too awful at html/css/js to start working on that, but I can help gluing everything together if somebody has html/css/js ready and general idea how entire thing should work/look like.

@JustArchi JustArchi added ✨ Enhancement Issues marked with this label indicate further enhancements to the program, such as new features. 🤝 Help welcome Issues marked with this label are open for help. If you could offer us a hand, please do! ⛔ On hold Issues marked with this label are blocked from being worked on, very often due to third-parties. 🙏 Wishlist Issues marked with this label are wishlisted. We'd like to make them happen but they're not crucial. labels Aug 12, 2017
@KlappPc
Copy link
Contributor

KlappPc commented Aug 16, 2017

A minimal example using jquery can be found here:
#615

Sending commands and reading replys works in firefox and chrome (rest unchecked), loading the log, only in firefox. (and not in chrome).

For reading the logs nothing but jquery.load worked. But I am not sure if this functionality is really needed. Sending commands could be done without jquery.

@OmG3r
Copy link

OmG3r commented Nov 3, 2017

I'm using this ruby script to communicate with ASF through IPC.
This script can be compiled into an .EXE file which executes the commands and returns the value.
the compiled file would be approximatively 2.8MBs
This script assumes that the user did not edit neither IPChost nor IPCport, there can be some workarounds to get IPChost and IPCport without the user input.

require 'open-uri'

x = 0
until x == 5
  begin
    puts "write the command to execute/'exit' to exit"
    command = gets.chomp
    if command == "exit"
      puts "Exiting the program"
      x = 5
    else
      remove_exclamation = command.sub "!", ""
      space_command = remove_exclamation.gsub " ", "%20"
      output = open("https://127.0.0.1:1242:1242/IPC?command=#{space_command}", :read_timeout => 900).read
      output.strip!
      puts "#{output}"
      puts ""
      end
  rescue
    puts "Something went wrong"
    puts ""
  end
end

@kaoyusu
Copy link

kaoyusu commented Nov 26, 2017

<body>
<form action="http://127.0.0.1:1242/IPC" method="get" target="output">
<input name="command" /><input type="submit" value="Send" />
</form>
<iframe name="output"/>
</body>

_2017-11-27_00-21-37

@Pandiora
Copy link
Contributor

I would say use a grid, like the one from syncfusion or bootstrap, with a bar on top for all possible actions. Then if you want to execute an action on one or multiple bots, just check the boxes before each bot (or just all) and click the corresponding button. A second tab in the menu could show a log. AdminLTE, which uses Bootstrap and could be a nice looking framework.

@Benman2785
Copy link

Benman2785 commented Dec 6, 2017

@kaoyusu - how to use it?

EDIT: hehe - yo soy muy stupido xD
simply make it as html and "run" it

@Benman2785
Copy link

ASF-IPC-GUI.zip
asf-ipc-gui
works and has some stuff in it

@Nuklon
Copy link

Nuklon commented Dec 7, 2017

@JustArchi
Could we keep compatibility with ASFui's? With 3.0.5.1 it ain't working anymore.

@JustArchi
Copy link
Member Author

JustArchi commented Dec 7, 2017

Then ASFui should be updated to match new structure - it was clearly stated in V3 migration article that current way of accessing IPC is considered to be temporary until a good idea of a proper API is ready. I don't plan supporting obsolete and much more problematic to execute ways such as /IPC?command=version if user can just call /Api/Command/version instead.

Now the API is ready and I do plan to keep it as compatible as possible in future versions, but I don't want to hold on obsolete temporary dependencies that were announced to be temporary in the first place.

@JustArchi
Copy link
Member Author

JustArchi commented Dec 7, 2017

It'd be a good idea to make use of extra time the version still being in pre-release and let @alvr correct the URL, since the change is really misc.

@Nuklon
Copy link

Nuklon commented Dec 7, 2017

OK, would be nice if you could update the wiki then to include the changed IPC endpoint.

@Nuklon
Copy link

Nuklon commented Dec 7, 2017

BTW, doesn't ASF output received IPC commands to console anymore? This was rather useful.

@JustArchi
Copy link
Member Author

OK, would be nice if you could update the wiki then to include the changed IPC endpoint.

Would be nice if people read 🤔

@dfmcvn
Copy link

dfmcvn commented Dec 9, 2017

Is there any way to setup SSL for IPC server? 🤔

@JustArchi
Copy link
Member Author

JustArchi commented Dec 9, 2017

Nope, that would require from ASF server to have valid SSL certificate and add extra overhead.

If you need ASF IPC interface over SSL then I strongly recommend to use reverse-proxy. Nginx can be a very good solution for that.

location / {
	proxy_pass http://127.0.0.1:1242;
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
}

Then you can just set your website to use any protocol and port you want to, including securing it with SSL and certificate.

@dfmcvn
Copy link

dfmcvn commented Dec 9, 2017

Oh, forgot that I can use nginx as a proxy. 👍
Thank you very much.

@dfmcvn
Copy link

dfmcvn commented Dec 9, 2017

Another way, change IPC server to *:80 and use Cloudflare Flexible SSL. Point domain to server's IP 😁
https://i.imgur.com/WH55QL7.jpg

@Benman2785
Copy link

i always get 404 when i run it on my rootserver
it runs and it farms - and IPC also is active - but i cant hand over and correct commands

@guihkx
Copy link

guihkx commented Dec 9, 2017

I'm not sure if IPC isn't completely ready yet (as of update V3.0.5.1), but issuing commands via POST request isn't working for me. Here's what I'm trying to do:

curl -v -X POST 'http://127.0.0.1:1242/Api/Command/version'
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 1242 (#0)
> POST /Api/Command/version HTTP/1.1
> Host: 127.0.0.1:1242
> User-Agent: curl/7.57.0
> Accept: */*
> 
< HTTP/1.1 411 Length Required
< Content-Type: text/html
< Server: Microsoft-NetCore/2.0
< Date: Sat, 09 Dec 2017 18:46:13 GMT
< Content-Length: 24
< Connection: close
< 
* Closing connection 0
<h1>Length Required</h1>% 

I also got this on ASF:

2017-12-09 16:40:59|dotnet-16064|FATAL|ASF|OnUnobservedTaskException() System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.) ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.
   at System.Net.HttpListenerResponse.CheckDisposed()
   at System.Net.HttpListenerResponse.set_ContentType(String value)
   at ArchiSteamFarm.IPC.<ResponseString>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<ResponseJson>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<ResponseJsonObject>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleApiCommandGeneric>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleApiCommand>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleApi>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleAuthenticatedRequest>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleRequest>d__17.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.
   at System.Net.HttpListenerResponse.CheckDisposed()
   at System.Net.HttpListenerResponse.set_ContentType(String value)
   at ArchiSteamFarm.IPC.<ResponseString>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<ResponseJson>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<ResponseJsonObject>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleApiCommandGeneric>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleApiCommand>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleApi>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleAuthenticatedRequest>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ArchiSteamFarm.IPC.<HandleRequest>d__17.MoveNext()<---

@Benman2785
Copy link

new IPC is broken
old IPC of version 1.0.4.9 is working

@JustArchi
Copy link
Member Author

JustArchi commented Dec 9, 2017

@guihkx You have your error clearly stated in the response:

< HTTP/1.1 411 Length Required

You can't send POST request without specifying Content-Length. Refer to HTTP RFC if you're confused - https://tools.ietf.org/html/rfc7231#section-6.5.10

As for the exception it's good that you reported it, will cover it in V3.0.5.2.

@Benman2785 Nothing is broken, thanks for your concern.

@JustArchi
Copy link
Member Author

@guihkx You can continue hunting bugs in V3.0.5.2, especially all IPC-related exceptions 🙂

@guihkx
Copy link

guihkx commented Dec 9, 2017

I just tried to replicate the request as stated in this section of the Wiki... Am I missing something? I really don't know.

@JustArchi
Copy link
Member Author

I just told you what you're missing - read again.

@guihkx
Copy link

guihkx commented Dec 9, 2017

Yes, the Content-Length header, but what should I put in the request body? The example in the Wiki doesn't tell me what.

@JustArchi
Copy link
Member Author

The example on the wiki doesn't require request body 🙂

@KlappPc
Copy link
Contributor

KlappPc commented Dec 22, 2017

@Basdower not that I am aware of.

@Benman2785 404 means you screwed up the link. Check the wiki for correct syntax.

@Benman2785
Copy link

Benman2785 commented Dec 22, 2017

@KlappPc i know - but here is my problem ;)

i can do:
< body> < form action="http://IP:1242/Api/Command/status BOT" method="GET" target="output"> < input type="submit" value="status BOT" /> < /form> < iframe name="output"/> < /body>

this works - but i have to hardcode any command to the button - because if i try

< body> < form action="http://IP:1242/Api/Command" method="get" target="output"> < input type="text"><input type="submit" value="Send"> < /form> < iframe name="output"/> < /body>

it wont work - i always get 404

@deluxghost
Copy link

@Benman2785 i think you must provide a command in url

action="http://IP:1242/Api/Command"

@KlappPc
Copy link
Contributor

KlappPc commented Dec 22, 2017

@Benman2785

You need to append the command using javascript. The second example will append stuff as parameters, while you need it there as in your first example.
Just do it without the iframe and look at the URL of the page you are getting to.

@Benman2785
Copy link

Benman2785 commented Dec 22, 2017

@KlappPc https://discord.gg/qb7mHwV - pls find me there ;)

@deluxghost as i did in the first try - but that is not what i want - i want a textfield where i can put my command and execute it

lets say i want to redeem a key - i simply want to copy it in the textarea and klick redeem ;)

@KlappPc
Copy link
Contributor

KlappPc commented Dec 22, 2017

@Benman2785
I do not have discord and I do not give private support, there are enough examples out there, to figure it out.

This can give you a hint
https://www.steamgifts.com/discussion/gCxhN/archis-steam-farm-asf-steam-cards-farmer-and-much-more-windowslinuxos-x/search?page=61#Xqj47Ox
But that a specialiced thing for one purpose.

@Benman2785
Copy link

thank you ;)
i simply wanted to avoid javascript

Merry X-Mas // dennoch schone Weihnachten ;)

@KlappPc
Copy link
Contributor

KlappPc commented Dec 22, 2017

@Benman2785
Well, without javascript you page is static. And since the commands are not appended as parameter, there is no way to do that with pure html without coding one button for each command (including parameters to that command.)

Danke gleichfalls.

@Benman2785
Copy link

Benman2785 commented Dec 22, 2017

that was the problem i was looking a solution for
now i simply use your "hint" and modify it to redirect the output into the iframe

thank you again

edit - got it - also working with all my bots (in one file) ;)

@benutzer193
Copy link

benutzer193 commented Dec 26, 2017

As you are working on the new IPC interface right now, how about adding more information to the response, so you do not have to parse the Result to receive the info you want?

E.g.:

curl -s -X POST -d '' "http://127.0.0.1:1242/Api/Command/redeem^%20bot%20SD,SF%20abcde-abcde-abcde%20aaaaa-aaaaa-aaaaa" | jq
{
  "Message": "OK",
  "Resulttext": "\n<bot> Key: abcde-abcde-abcde | Status: Fail/BadActivationCode\n<bot> Key: aaaaa-aaaaa-aaaaa | Status: Fail/BadActivationCode",
  "Result": [
    {
      "Key": "abcde-abcde-abcde",
      "Status": false,
      "Statustext": "BadActivationCode",
    },
    {
      "Key": "aaaaa-aaaaa-aaaaa",
      "Status": false,
      "Statustext": "BadActivationCode",
    }
  ],
  "Success": true
}

The structure is just the first I came up with. This can be improved and enhanced by missing information, e.g. bot instance.
It is just meant as an idea. I think it would help GUI developers and make scripting a lot simpler. Also it would allow enhancing the response without potentially breaking current parsers.

@nakagawadev
Copy link

this is my console :B
https://i.imgur.com/2ZL8hof.png

@MrBurrBurr
Copy link
Member

@Zarat99

looks nice! maybe we can work together on the design.

@JustArchi

Happy New Year. I am back from my holiday and will work on the GUI, so its half way functional. Then I will send it to you so you can merge it into ASF. Thanks for all the new features in IPC!

@JourneyOver
Copy link

@MrBurrBurr How's the GUI coming along? Wouldn't mind getting my hands on it :D

@Benman2785
Copy link

Benman2785 commented Jan 8, 2018

asf-gui_lowbob

thats my ugly but working "gui"

@MrBurrBurr
Copy link
Member

@JourneyOver

I am working on it but I cant spend as much time on it as I would like to due to work and other projects. Maybe I should just upload the unfinished, "dirty" base GUI. That way more people could work on it together and maybe help me out.

What do you think @JustArchi?

@JourneyOver
Copy link

@MrBurrBurr know how it is, as I deal with that same problem daily :x I honestly wouldn't mind it even in a "dirty" state as you put it as it's a lot better than what I'd ever be able to come up with more than likely >..<

@JustArchi
Copy link
Member Author

JustArchi commented Jan 9, 2018

@MrBurrBurr That's up to you, you can post it if you want more people to work on it and eventually send PR, or finish it yourself. When it comes to me I'm just waiting for somebody to send a PR and start a thing, it's natural that other people will improve it once it's merged.

@Benman2785
Copy link

@MrBurrBurr
i would appreciate if you upload your "dirty" GUI
i would help (if i can) to clean it ;)

@MrBurrBurr
Copy link
Member

I will do some final clean up and remove some of the unfinished parts (like config generator). Then I will send a PR so you can implement the basic version of the GUI. In that way we got a base where everyone else that wants to help can do so.

I guess the code will also turn from ugly into something useable once we got a base. 🙂

@Benman2785
Copy link

awesome ;)

@JourneyOver
Copy link

@MrBurrBurr how is cleanup going? still waiting to get my hands on your GUI xD

@MrBurrBurr
Copy link
Member

To be honest I am kinda stuck right now.

Clean up is almost done but my main problem right now is getting rid of all the hardcoded shit I used when the GUI was just ment for me. For example reading the config values like IPC Host and IPC Port. Right now I am not using node.js or any other manager so reading values from a JSON file is kinda dirty.

I am open to help if anyone know how to counter that problem.

@OmG3r
Copy link

OmG3r commented Jan 23, 2018

@MrBurrBurr , what about a cookie ?

@MrBurrBurr
Copy link
Member

MrBurrBurr commented Jan 26, 2018

I managed to solve some of my problems.

Right now the code is still a mess and here and there are some bugs. Still I want to release it finally so more people can work on it and so we finally get things started.

@JustArchi
I tested the GUI with the latest stable version of ASF (3.0.5.9) and it should work. Should I just upload the new files in a pull request and you will then clean everything up? The GUI folder needs to be located inside of ASF folder,

While doing the clean up I also came up with a lot of ideas for the GUI. I think we should make a list with improvements that we want to have (like you did before with issue #659).

Here are some:

  • Config Generator / Config Changer (change current values of ASF.json or Bots.json)
  • Bots Overview (manage bots via buttons example: https://i.imgur.com/SZWs48P.png)
  • Stats Overview on dashboard (memory usage for example, process name etc)
  • Wiki in sidebar (searchable)
  • News from ASF (example: latest updates) in sidebar
  • GUI improvements as task progress in sidebar
  • Add ToDo List (this list for example) on dashboard
  • Add IPC GUI Password protection? Like a login?

@JourneyOver
Copy link

JourneyOver commented Jan 26, 2018

@MrBurrBurr I'm not archi but I say do it! but that's just me wanting the GUI already xD

@JustArchi
Copy link
Member Author

JustArchi commented Jan 26, 2018

The GUI folder needs to be located inside of ASF folder

What do you mean by that? Physical location of files doesn't matter for functionality.

Just create Website folder in main ASF directory and put all html/css/js files there (in your wanted structure), then send a PR. I'll glue it with IPC server when I find some free time.

@JustArchi
Copy link
Member Author

Closed by #731

fadillzzz pushed a commit to fadillzzz/ArchiSteamFarm that referenced this issue Apr 11, 2018
I completely forgot that we intentionally omit sensitive details, so bot config update API should have a way to inherit them without exposing, this will do.

Note to self: ALWAYS use custom JSON classes, so I won't need to break API just like like now, at worst I'll add new acceptable properties.
@lock lock bot locked as resolved and limited conversation to collaborators Jun 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✨ Enhancement Issues marked with this label indicate further enhancements to the program, such as new features. 🤝 Help welcome Issues marked with this label are open for help. If you could offer us a hand, please do! ⛔ On hold Issues marked with this label are blocked from being worked on, very often due to third-parties. 🙏 Wishlist Issues marked with this label are wishlisted. We'd like to make them happen but they're not crucial.
Projects
None yet
Development

No branches or pull requests