<unshadow>
Someone here with a little C know how ? :) jhass, havenwood ?
<jhass>
maybe, just ask your question and be patient :P
Ven has joined #crystal-lang
<strcmp1>
the fact that so many people come from #nim im going to guess there's more than just those two ;)
asterite has joined #crystal-lang
<unshadow>
Lets try, I want to add a new fun to a lib, checking the file.h in my OS I can see the function is there, but, when calling it from crystal I get : OpenSSL::SSL::Context:(.text+0x146): undefined reference to `SSL_CTX_set_mode'
<unshadow>
but in ssl.h I can see in line 785 : # define SSL_CTX_set_options(ctx,op) \
<jhass>
crystal doesn't read header files
<jhass>
you have to do the lib declaration manually
<asterite>
also, that's a macro
<unshadow>
@[Link("ssl")]
<asterite>
well, it's a #define, so there's no real function there
<unshadow>
yeha, I want to add fun ssl_ctx_set_options = SSL_CTX_set_mode(context : SSLContext, text : Int32) : Int32
<asterite>
unshadow: I mean, SSL_CTX_set_mode doesn't really exist, only in C programs that use that header. You'll have to do what SSL_CTX_set_mode does in crystal code
<unshadow>
ohhh
<asterite>
what's the definition of SSL_CTX_set_options ?
<jhass>
long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
<jhass>
SSL_CTRL_OPTIONS is another macro or a constant
<asterite>
These C people don't trust inliners :-P
<jhass>
well, back then probably rightfully so^^
<unshadow>
So, to create the ssl_ctx_set_options, I actually need to do a fun for SSL_CTX_ctrl ?
<jhass>
I see none already, so yeah
<unshadow>
what the point of the NULL in the end ?
<jhass>
it's passing a null pointer to parg
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
The SSL_*_ctrl() family of functions is used to manipulate settings of the SSL_CTX and SSL objects. Depending on the command cmd the arguments larg, parg, or
<jhass>
fp are evaluated. These functions should never be called directly. All functionalities needed are made available via other functions or macros.
<jhass>
hf fun reading source to find out why ;)
<unshadow>
These functions should never be called directly :(
<jhass>
I bet other bindings do
<unshadow>
well... fun ssl_ctx_set_options = SSL_CTX_ctrl(context : SSLContext, text : Int32, Void*) : Int32
<jhass>
oh, leaving an argument unnamed is valid?
<unshadow>
not sure that why text : Int32 haha
<jhass>
I don't think that signature is right
<unshadow>
jhass, what do you mean ?
<jhass>
I'd go for (context : SSLContext, command : LibC::IntT, long_arg : LibC::LongT, pointer_arg : Void*)
<strcmp1>
jhass, clicking on "new" doesn't seem to work btw, empty white page appears.
<unshadow>
Lol, I do :)
sandelius has joined #crystal-lang
<strcmp1>
empty except for Run #7r
<jhass>
huh? weird
<strcmp1>
just me?
<jhass>
strcmp1: mind peeking at your error console?
<strcmp1>
sure
<unshadow>
nope, if you wait a while and do "new" it gets stuck
<unshadow>
for me too
Ven has joined #crystal-lang
<asterite>
asterite: what would String#slice be?
<jhass>
oh, interesting
<strcmp1>
it's empty here, jhass, no errors at all
<unshadow>
asterite, returns Slice.new for the string ?
<jhass>
okay, the new button is broken here too, but initial load and shortcut is fine
ponga has quit [Remote host closed the connection]
ponga has joined #crystal-lang
<jhass>
well, that was dumb, fix deployed for the button
<jhass>
unshadow: asterite I'd vote for .to_slice
<jhass>
strcmp1: what browser?
<asterite>
And it'll be a slice of UInt8?
<unshadow>
sure, .to_slice is better
<jhass>
I guess
<unshadow>
yeha Uint8 array
<asterite>
Yes, we can add it
<unshadow>
yey !
<asterite>
But maybe we need a new type, ImmutableSlice, which doesn't have #[]=
<asterite>
Slice would just inherit ImmutableSlice
<asterite>
The thing is, String is immutable, wouldn't be nice to accidentally change it
<jhass>
well, you could with to_unsafe already too, no?
<asterite>
Yes, you can do Slice.new(string.to_unsafe, string.bytesize)
<asterite>
and that makes it explicit that you are going into the unsafe world ;-)
<asterite>
we should remove the "cstr" method, I think...
<jhass>
I view Slice similar unsafe
<asterite>
Yeah, me too... it's safer than a pointer, but still kind of like a pointer, so unsafe...
<jhass>
so I'd argue what to_unsafe lets you do, to_slice should too
<jhass>
being really just a convenience wrapper around Slice.new(to_unsafe, my_length)
<asterite>
We could still have ImmutableSlice, it's easy to do and will be a bit safer
<asterite>
What do you need to do with that slice?
<strcmp1>
jhass, chrome 42.0.2311.135
<unshadow>
What would be "const char *str" in Crystal ? I used UInt8* is that right ?
<jhass>
strcmp1: works fine here with Chromium Version 42.0.2311.135 (64-bit) :/
<jhass>
yes
<unshadow>
jhass, yes was for me ?
<jhass>
yes
<unshadow>
thanks
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: http://git.io/vTcth
<crystal-gh>
crystal/master 8c29b8b Ary Borenszweig: Parse comments in macros. This allows macros that generate code to also generate doc comments by using interpolation
<crystal-gh>
crystal/master 12d3a04 Ary Borenszweig: Added many options to `String#to_i` to make it very flexible: whitespace, underscore, prefix and strict
<unshadow>
Oh, I didnt know you were working on SSL too XD
<jhass>
eh, look at the commit date ;)
<unshadow>
4 months ago, I see ;)
<unshadow>
Btw, this is the first time I think I actually did a PR for a project, I'm kinda happy :)
<jhass>
congratz ;)
<unshadow>
It still has some issues though, right now the code I wrote in the PR should allow a full functional SSL Socket, but, Something is broken some where, so the client never get a SSL Cipher offer ... it's wierd
<travis-ci>
manastech/crystal#2345 (master - 8c29b8b : Ary Borenszweig): The build is still failing.
<asterite>
unshadow: we'll probably merge your PR, but I know nothing about openssl so I really can't review the code, I'll ask @waj when I see him next time... or if jhass thinks it's OK too, I'll merge it
ponga has quit [Remote host closed the connection]
datanoise has quit [Ping timeout: 265 seconds]
<jhass>
we should start calling all these things TLS
<jhass>
mh, we should make Crystal's SSLSocket DANE aware
<unshadow>
TBH you are right, Using SSLv3 or SSLv2 is insecure, SSLv2 is long dead, and SSLv3 has POODLE for CBC based ciphers, and BMA for RC4 based ciphers
<asterite>
Department of Advanced Nursing Education?
<unshadow>
DNS-based Authentication of Named Entities
<asterite>
Oh
<unshadow>
Basic need for DNS-SEC
<jhass>
I think there are OpenSSL callbacks to hook into validation, the hard part would be getting authenticated DNS replies
<jhass>
uh, no DNSSEC doesn't depend on DANE, it's the other way around ;)
<jhass>
DANE replaces the CA system with DNSSEC
<unshadow>
True, my bad
<unshadow>
the sec I get SSLSocket to act nicly in server mode, I can start writing my reverse proxy in crystal, I also want to try and re-write my ssl scanner in crystal, could be a cool project
ponga has joined #crystal-lang
<asterite>
unshadow: you can always monkey-patch the standard library until we merge your pull request :-)
<unshadow>
no worries, TBH becuase my lack of C style expireance I would really like to give as much people the time to review and edit the changes, so I dont mind if it would take some time.
kulelu88 has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
asterite has quit [Quit: Page closed]
ponga has quit [Remote host closed the connection]
<boghison>
Hi! I just found out about Crystal and I'm very interested in being able to do C bindings. I have one question though: is it possible to link to static libraires with @[Link]?
<questioner1337>
jhass: how do you use sizeof in crystal-lang ?
<jhass>
boghison: yes, that's just passed to -l
<jhass>
(of cc or ld, I don't remember, I think cc)