Skip to content

Conversation

nerijus
Copy link
Contributor

@nerijus nerijus commented Aug 14, 2025

Currently AMCP port 5250 listens on all interfaces:

ss -nlp|grep 5250
tcp   LISTEN 0      4096                                              0.0.0.0:5250             0.0.0.0:*    users:(("casparcg",pid=3534544,fd=112))

So it is possible for everyone from internet to connect to it and send commands (unless it is firewalled).
With this PR it is possible to specify IP addr like this:

--- casparcg.config.orig	2025-07-18 15:26:29.000000000 +0000
+++ casparcg.config	2025-08-14 15:31:52.387490375 +0000
@@ -19,6 +19,7 @@
     </channels>
     <controllers>
         <tcp>
+            <host>127.0.0.1</host>
             <port>5250</port>
             <protocol>AMCP</protocol>
         </tcp>

Now it listens on 127.0.0.1 only:

ss -nlp|grep 5250
tcp   LISTEN 0      4096                                            127.0.0.1:5250             0.0.0.0:*    users:(("casparcg",pid=965101,fd=113))

This PR was made with the help of AI. If <host>127.0.0.1</host> is omitted, then it behaves like before. The value should be IP addr, not hostname.

Copy link
Member

@Julusian Julusian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say that it would also be good to have this documented in the examples block in the config file, but it appears that this section of config is not expressed there, only in the active portion of the file, so maybe not

unsigned short port);

AsyncEventServer(std::shared_ptr<boost::asio::io_context> io_context,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this constructor without the host is being used or is helpful, and could be removed

a.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
a.bind(endpoint);
a.listen();
return a;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason for this constructor being more verbose than before?
Previously it was doing acceptor_(*io_context_, tcp::endpoint(tcp::v4(), port)), so it looks like this could be done with something along the lines of return tcp::acceptor(*io_context_, endpoint); instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants