-
Notifications
You must be signed in to change notification settings - Fork 23
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
fdgt support (Saves money for testing!) #164
Comments
You can just connect with a tokio TcpStream. The "client" portion of this crate is intentionally very thin, you can give any let connector = Connector::new(|| {
tokio::net::TcpStream::connect("some_address:port").await
});
// ...
runner.run_to_completion(connector).await; for example. you could just do this yourself if you require TLS: twitchchat/src/native_tls/mod.rs Lines 25 to 41 in 18c7a1e
|
I'll take a look at this. Thank you for the quick response! |
Tested and pull request submitted for the fdgt website |
To note here is that the connectors will soon change, see #163 |
I'll have a similar design for the 'connectors' I believe. Or it'll be trait-based. I'm still determining the high-level approach of abstracting/feature-gating different external |
As long as I can specify a custom server address, everything should be fine |
I just implemented it. the dev branch is still a major WIP. But the new design should be easier to use. Here is the implementation: twitchchat/twitchchat/src/connector.rs Lines 24 to 71 in 8003f0e
You basically create a And then you'd use something like let config = ConnectorConfig::unconfigured().with_addrs("localhost:6667");
let connector = tokio::Connector::new(config);
// ...
runner.run_to_complete(connector).await; You can also implement that |
I want to reopen this issue with the new version of the crate. I can't seem to connect to fdgt using the custom connector. Here's the error I got: Here's the code for the connector and connection. Can you please let me know if I did this right? If so, I'm going to talk with the fdgt dev async fn connect(user_config: &UserConfig, channels: &[String]) -> KingResult<AsyncRunner> {
let connector = Connector::custom("irc.fdgt.dev:6667")?;
let mut runner = AsyncRunner::connect(connector, user_config).await?;
println!("Connected to fdgt!");
for channel in channels {
println!("attempting to join '{}'", channel);
runner.join(&channel).await?;
println!("joined '{}'!", channel);
}
Ok(runner)
} |
Info: I don't need to connect to a certain channel and don't need credentials. I just need a writer to send messages with and I need to just connect to the server itself |
So, I can't get it to connect with manual code. Is that the right port (and domain)? The connection is being refused by the server which usually indicates that. |
Looking through the connection code for the other 3 libraries listed on the site -- the two javascript ones use websockets -- which I don't support (yet). My crate only does tcp (and tls over tcp) connections. If they are expecting something on, say, port 80 (ws) or 443 (wss) then I'd have to add WsConnector/WssConnector types for this to work. A normal let config = UserConfig::builder()
.anonymous()
.enable_all_capabilities()
.build()
.unwrap();
let conn = std::net::TcpStream::connect("irc.fdgt.dev:6667").unwrap();
twitchchat::Encoder::new(&conn)
.encode(twitchchat::commands::register(&config))
.unwrap();
for msg in twitchchat::Decoder::new(&conn) {
eprintln!("{:#?}", msg.unwrap())
} |
I was able to connect in 0.11 and send events, so that URL should work unless something was changed. I'll talk to the dev and possibly add him into this conversation |
And I just tried with a websocket crate and I cannot connect with it either. async_std::task::block_on(async move {
let addr = "ws://irc.fdgt.dev";
let (mut stream, response) = async_tungstenite::async_std::connect_async(addr)
.await
.unwrap(); // <-- fails here -- so the server is refusing the connections
eprintln!("{:#?}", response);
while let Some(msg) = stream.next().await {
eprintln!("{:#?}", msg)
}
}); |
Hey there, I'm the |
The docs do not list the port, but because of the (This crate can use either TLS library (one is a wrapper around the "system" TLS library (schannel, secureconnect, openssl, libressl, etc) and the is an audited library written mostly in Rust.) |
And oddly enough, they fail at different points. // native-tls = "0.2.4"
// rustls = "0.18.1"
// webpki = "0.21.3"
// webpki-roots = "0.20.0"
use std::io::{Read, Write};
const DOMAIN: &str = "irc.fdgt.dev"; // also tried just 'fdgt.dev'
const ADDRESS: &str = "irc.fdgt.dev:6667";
type Result<R> = std::result::Result<R, Box<dyn std::error::Error>>;
fn native_tls() -> Result<impl Read + Write> {
let stream = std::net::TcpStream::connect(ADDRESS)?;
let connector = native_tls::TlsConnector::new()?;
let stream = connector.connect(DOMAIN, stream)?;
Ok(stream)
}
fn rustls() -> Result<impl Read + Write> {
let stream = std::net::TcpStream::connect(ADDRESS)?;
let mut config = rustls::ClientConfig::new();
config
.root_store
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
let client = rustls::ClientSession::new(
&std::sync::Arc::new(config),
webpki::DNSNameRef::try_from_ascii_str(DOMAIN)?,
);
let stream = rustls::StreamOwned::new(client, stream);
Ok(stream)
}
fn connect<IO: Read + Write>(connect: impl FnOnce() -> Result<IO>) -> bool {
let login = b"PASS justinfan4567\r\nNICK justinfan4567\r\n";
let mut stream = match connect() {
Ok(stream) => stream,
Err(err) => {
eprintln!("cannot connect: {}", err);
return false;
}
};
match stream.write_all(login) {
Ok(..) => {
eprintln!("succesfully wrote to socket");
true
}
Err(err) => {
eprintln!("cannot write: {}", err);
false
}
}
}
fn main() {
if !connect(native_tls) {
eprintln!("failed for native_tls")
}
if !connect(rustls) {
eprintln!("failed for rustls")
}
}
// cannot connect: An existing connection was forcibly closed by the remote host. (os error 10054)
// failed for native_tls
// cannot write: An existing connection was forcibly closed by the remote host. (os error 10054)
// failed for rustls I don't have the time to deal with figuring out where exactly the TLS handshake is failing. But this little example is essentially what this crate does for either TLS library. |
Ah, it turns out I introduced an issue with TCP with some updates last week. The issue should now be resolved on port 6667. Port 6697 sill be fixed up shortly, as well. |
I still cannot get either rust library to connect. Both are failing to complete the connection. I'll try on with openssl, libressl and boringssl to hopefully figure out where the misconfiguration is. On Windows, SChannel (via native-tls) is reporting an unsupported cipher scheme (although the TLS cert for the site reports TLS_AES_128_GCM_SHA256 which is definitely a common cipher for TLS v1.3). And rustls isn't being helpful and just saying the server sends a corrupt message after the 'hello' part of the handshake. update:
And is implied that in the next stable release will be supported ref |
I just tested a |
I can also confirm the same errors over TCP using port 6667 using @museun's code Here are the errors that I receive using WSL
|
I've started work on adding a websocket client so this service can be used, but I've ran into some issues. First, this is the initial response I'm given.
The Although its not explicitly stated in IRCv3.1, IRCv3.2 -- all of the examples show the server repeating the capability verbatim. E.g.
So, my parser will reject these messages. And with the IETF draft, the ABNF for (the important bits of the grammar)
I'm going to go ahead and special case this (because Twitch's IRC isn't really spec compliant so whatever), but I thought I should bring it up. |
I was recently informed of this new service called fdgt which is a mock twitch irc server that allows you to test various events such as subs/bits without spending a dime.
However, connecting to this service requires me to specify a server address to connect to on bot startup. If possible, can you add the ability to change the server URL when needed as shown here
The text was updated successfully, but these errors were encountered: