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

How to send netconf xml #72

Open
sak0 opened this issue Jul 30, 2018 · 2 comments
Open

How to send netconf xml #72

sak0 opened this issue Jul 30, 2018 · 2 comments

Comments

@sak0
Copy link

sak0 commented Jul 30, 2018

example help.

May i send this xml packet with go-netconf like this:
Could you please give an example to do it?

<rpc message-id ="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:h3c="http://www.h3c.com/netconf/base:1.0"> <get> <filter type="subtree"> <top xmlns="http://www.h3c.com/netconf/data:1.0"> <VLAN> <VLANs> <VLANID> <ID></ID> <Description></Description> <Name></Name> <RouteIfIndex></RouteIfIndex> <UntaggedPortList></UntaggedPortList> <TaggedPortList></TaggedPortList> <Shared></Shared> </VLANID> </VLANs> </VLAN> </top> </filter> </get> </rpc>]]>]]>

@sak0
Copy link
Author

sak0 commented Jul 30, 2018

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/Juniper/go-netconf/netconf"
	"golang.org/x/crypto/ssh"
)

func doRpc(s *netconf.Session, xml string) {
	reply, err := s.Exec(netconf.RawMethod(xml))
	if err != nil {
		panic(err)
	}
	fmt.Printf("Reply: %+v", reply)
}

func main() {
	var sshconfig ssh.Config
	sshconfig.SetDefaults()
	cipherOrder := sshconfig.Ciphers
	sshconfig.Ciphers = append(cipherOrder, "aes128-cbc")
	
	sshConfig := &ssh.ClientConfig{
		Config:			sshconfig,
		User:            "admin",
		Auth:            []ssh.AuthMethod{ssh.Password("admin")},
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
		Timeout: 5 * time.Second,
	}

	s, err := netconf.DialSSH("10.0.2.2:830", sshConfig)

	if err != nil {
		log.Fatal(err)
	}

	defer s.Close()

	fmt.Println(s.ServerCapabilities)
	fmt.Println(s.SessionID)
	
	xml := `
<rpc message-id ="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:h3c="http://www.h3c.com/netconf/base:1.0">
<get>
   <filter type="subtree">
   <top xmlns="http://www.h3c.com/netconf/data:1.0">
<VLAN>
  <VLANs>
    <VLANID>
      <ID></ID>
      <Description></Description>
      <Name></Name>
      <RouteIfIndex></RouteIfIndex>
      <UntaggedPortList></UntaggedPortList>
      <TaggedPortList></TaggedPortList>
      <Shared></Shared>
    </VLANID>
  </VLANs>
</VLAN>
</top>
    </filter>
  </get>
</rpc>
	`
    fmt.Printf("%s", xml)
	
	doRpc(s, xml)
}

the code above will hung forever.

@nemith
Copy link
Collaborator

nemith commented Jul 22, 2022

I am going to guess this may have to do with #89 and fix may be there.

nemith pushed a commit that referenced this issue Mar 13, 2024
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from
0.18.0 to 0.19.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/crypto/commit/405cb3bdea78b1b48ee79096733841247a944de0"><code>405cb3b</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/crypto/commit/913d3ae7415ace5edad6750b7c9192ac7518e9df"><code>913d3ae</code></a>
x509roots/fallback: update bundle</li>
<li>See full diff in <a
href="https://github.com/golang/crypto/compare/v0.18.0...v0.19.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/crypto&package-manager=go_modules&previous-version=0.18.0&new-version=0.19.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants