2024-04-15 02:39:28 +09:00
package main
import "C"
import (
"encoding/json"
)
func main ( ) { }
2024-04-15 17:10:06 +09:00
// para: json of map[host string][]addr:port string
//
//export add_dns
func add_dns ( para * C . char , is_ipv6 C . int ) * C . char {
m := map [ string ] [ ] string { }
err := json . Unmarshal ( stringToBytes ( C . GoString ( para ) ) , & m )
if err != nil {
return C . CString ( err . Error ( ) )
}
if is_ipv6 != 0 {
if ! canUseIPv6 . Get ( ) {
return C . CString ( "cannot use ipv6" )
}
dotv6servers . add ( m )
return nil
}
dotv4servers . add ( m )
return nil
2024-04-15 02:39:28 +09:00
}
2024-04-15 17:10:06 +09:00
// para:
//
// request("{\"method\":\"GET\","
// "\"url\":\"https://i.pximg.net/img-master/img/2012/04/04/21/24/46/26339586_p0_master1200.jpg\","
// "\"headers\":{"
// "\"Referer\":\"https://www.pixiv.net/\","
// "\"User-Agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0\""
// "}"
// "}");
//
2024-04-15 02:39:28 +09:00
//export request
func request ( para * C . char ) * C . char {
2024-04-15 23:58:32 +09:00
return C . CString ( cli . request ( C . GoString ( para ) ) )
2024-04-15 02:39:28 +09:00
}